Closed yoanlcq closed 6 years ago
Whoops, the correct algorithm is
var v = rigidbody.velocity;
v.x = 0f;
v.z = 0f;
v += ax * Vector3.ProjectOnPlane(camera.transform.right, Vector3.up).normalized;
v += ay * Vector3.ProjectOnPlane(camera.transform.forward, Vector3.up).normalized;
rigidbody.velocity = v.normalized * s;
To preserve the Y velocity.
I added the prototype I did in the project. (TestsScenes/follow camera). I'm gonna adapt this more seriously with the components you mentioned.
Closing because production has ended this afternoon. Thanks everyone!
cc @datross. We'll want to copy from your earlier prototype.
Small TODO list for this:
SeCamera
orCameraController
component which implements the camera as described in the technical specs.InputActions
, add a convenience method for mapping input directions to world-coordinates directions. We're gonna need this badly.Quoting the technical specs
Conceptually, our camera is represented by only the following variables (from which the transform is computed) :
We list other items we should add :
Mapping input to camera-relative movement
Let s be the speed factor for the hero, ax and ay be the input axes, and cam be the camera’s transform component; Then v, the velocity to give to the hero, may be computed by