Skip to content

Commit

Permalink
Fix end sequence local rotation for non-VR mode
Browse files Browse the repository at this point in the history
  • Loading branch information
tyson-kubota committed Dec 3, 2017
1 parent c613c27 commit e5df292
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
13 changes: 11 additions & 2 deletions EndSequence1stPerson.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,21 @@ function RotateTowardsDiamond (timer : float) {
var step = 1.0/timer;
var startRotation = transform.rotation;
var endRotation = Quaternion.Euler(-54,96,-2.3);


var myCameraParent = transform.Find("Player-cameras");
var parentRotation = myCameraParent ? myCameraParent.localRotation : Quaternion.identity;

while (i <= 1.0) {
i += step * Time.deltaTime;
var t : float = i*i * (3f - 2f*i); // smoothstep lerp
transform.rotation = Quaternion.Slerp(startRotation, endRotation, t);

// myCameraParent needs rotating too, because otherwise the local container object
// (tilted via FallingPlayer.playerTilt) will not be aligned to 0,0,0 local rotation,
// so the diamond target won't be centered in view. VR mode is unaffected by this,
// since the VR eye cameras aren't children of myCameraParent.
if (myCameraParent) {
myCameraParent.localRotation = Quaternion.Slerp(parentRotation, Quaternion.identity, t);
}
yield;
}
}
Expand Down
8 changes: 5 additions & 3 deletions FallingPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -587,10 +587,12 @@ function playerTilt() {
if (FallingLaunch.hasSetAccel == false) {
FallingLaunch.accelerator = FallingLaunch.calibrationRotation * Input.acceleration;
}
tiltAroundZ = FallingLaunch.invertHorizAxisVal * Mathf.Clamp((FallingLaunch.flipMultiplier * (-FallingLaunch.accelerator.y * tiltAngle)), -tiltAngle, tiltAngle);
tiltAroundX = FallingLaunch.invertVertAxisVal * Mathf.Clamp((FallingLaunch.flipMultiplier * (-FallingLaunch.accelerator.x * tiltAngle)), -tiltAngle, tiltAngle);
tiltAroundX = FallingLaunch.invertVertAxisVal * Mathf.Clamp((FallingLaunch.flipMultiplier * (-FallingLaunch.accelerator.x * tiltAngle)), -tiltAngle, tiltAngle);

var target = Quaternion.Euler (tiltAroundX, 0, tiltAroundZ);
tiltAroundZ = FallingLaunch.invertHorizAxisVal * Mathf.Clamp((FallingLaunch.flipMultiplier * (-FallingLaunch.accelerator.y * tiltAngle)), -tiltAngle, tiltAngle);

var target : Quaternion = Quaternion.Euler (tiltAroundX, 0, tiltAroundZ);
// Dampen towards the target rotation
// Rotating the camera transform, not the Player transform itself, so the 3D clouds
// (which are the child of the Player object) have correct tilt context.
Expand Down

0 comments on commit e5df292

Please sign in to comment.