Question by
sarahnorthway · Jan 07, 2017 at 08:01 PM ·
rotationmovementdirectionflying
Character movement that ends with a specific facing
Can anyone suggest an algorithm for character movement where the character faces forward while moving, makes wide turns, and ends with a specific rotation? (think birds flying) For example:
This code works if I don't care what direction the character ends up facing:
void Update() {
Quaternion targetRotation = Quaternion.LookRotation(destination - transform.position);
transform.rotation = Quaternion.RotateTowards(transform.rotation, targetRotation, Time.deltaTime * turnSpeed);
transform.position += transform.forward * Time.deltaTime * moveSpeed;
}
Control points? Bezier curves? Something simpler?
movement-turns.png
(42.6 kB)
Comment
Your answer
Follow this Question
Related Questions
Struggling to get the rotation the player is moving in. 1 Answer
How do I rotate my object back to the world's up direction whilst keeping it's forward direction? 0 Answers
How can I incorporate a Rotation Towards the Mouse Position into this Script? I Tried. 0 Answers
Moving forward based off of Rotation 3 Answers
How to adjust a GameObject's rotation to face it's moving direction ? 0 Answers