Hello everybody
I’m doing a Strategy game with spaceship , and I have some difficulty to find how to achieve the rotate of my spaceship.
I don’t use keyboard to move in specific direction, I select a target to get destination position.
For now to move my spaceship, i’m using a simple code :
void FixedUpdate()
{
if (target != null)
{
if(Vector3.Distance(transform.position, target.position) < 5)
{
rb.velocity = Vector3.zero;
return;
}
rb.velocity = transform.forward * speed * Time.fixedDeltaTime;
var targetrotation = Quaternion.LookRotation(target.position - transform.position);
transform.rotation = Quaternion.Slerp(transform.rotation, targetrotation, turnSpeed * Time.deltaTime);
}
}
but would like to add the effect of movie’s spaceship. When my ship go to a destination, I would like to it to rotate on his Z axis and his Y axis.
For the example I post a image to explain :
So I would like to know if there is a way to achieve that ?
If someone can help me i’ll really appreciate because it’s seems to be sorcery for me and my programming level ^^’
Have a nice day