xyz AWESOME. I'm able to fully traverse a sphere now!! This should be my last question to put everything together. I understand using the basis to move (as you said, we need to take the rotation into account).
Here's my code (I'm using CharacterBody3D in my actual project, but the code is mostly the same as in the demo project, just using move_and_slide()
to handle movement):
Vector3 velocity = Vector3.Zero;
// Handle rotation based off of user input
Basis newBasis = Transform.Basis.Rotated(Transform.Basis.Y, turnInput * TurnRate * (float)delta);
Transform = new Transform3D(newBasis, Transform.Origin);
....bary normal collision code etc....
// Forward movement
velocity = -Transform.Basis.Z * forwardSpeed;
Velocity = velocity;
MoveAndSlide();
I believe I implemented the forward movement correctly. The only thing I cannot think of how to do is do this on the y-axis, especially after setting the velocity to -basis.z * speed
. I'm not exactly sure how to do this with the basis.
Would it be something similar to creating a new Transform3D
, setting the y-basis based on the up normal and the position in the world like basis.y = normal...
? I think I'm just struggling to imagine what the implementation would look like in code - reason being, I can't think of what I'd set the basis to/how I'd use it with movement calculations. All I can think to do is position.y = normal.get_collision_point() + ...
After this I'll have everything I need, so I'll work to figure out the hard edges etc. on my own (will start new thread if that happens) 🙂