So Robertbu has been super helpful with getting my basic game play setup. Basically I want to rotate the ship to ‘look at’ the new position it will be moving to over time. I do not want it to stop look in new direction then continue to move. I just want it to turn slowly into the direction while its moving. However when it’s stationary, I don’t want it to move until its fully looking in that direct.
Something on the lines like this Unity Capital Ship Space Sim 01: Environment and Movement (Proof of Concept) - YouTube
Demo: Félicitations ! Votre domaine a bien été créé chez OVHcloud !
#pragma strict
var speed = 35.0; // Degrees per second
var delay = 2.0;
private var direction = Vector3.zero;
private var qTo = Quaternion.identity;
private var timeStamp : float;
function Update () {
if (Input.GetMouseButtonDown(0)) {
var mousePos = Input.mousePosition;
mousePos.z = 1000; // select distance = 10 units from the camera
var worldPos = Camera.main.ScreenToWorldPoint(mousePos);
direction = (worldPos - transform.position).normalized;
timeStamp = Time.time + delay;
qTo = Quaternion.LookRotation(direction);
}
transform.rotation = Quaternion.RotateTowards(transform.rotation, qTo, speed * Time.deltaTime);
if (direction != Vector3.zero && timeStamp < Time.time)
transform.position += direction * Time.deltaTime;
}
At line 18 you’re setting the timeStamp to be 2 seconds in the future, and at line 25 you’re making the if statement not get triggered until those 2 seconds pass.
From what I see, after you click, your ship would stop having its position transformed, and then start again after 2 seconds.
What is the timeStamp meant to be doing, by the way?