private IEnumerator H(float vx, float vy, float vw)
{
vx = vx / 1000;
vy = vy / 1000;
vw = vw / 1000;
while (true)
{
transform.Translate((transform.forward * 1) * Time.deltaTime * vx, Space.World);
transform.Translate((transform.right * 1) * Time.deltaTime * vy, Space.World);
transform.Rotate((transform.up * 1000) * Time.deltaTime * vw, Space.World);
yield return 0;
}
}
Without using a function like MoveTowards in the code above
I want to make it move a certain distance.
I tried various methods, but it was not easy
If you want to move it a certain amount instantly, then just use that value in your calculation instead of Time.deltaTime
If you want it to move a certain amount over time, you can keep a simple float distanceTravelled
, when moving check how much you moved distanceTravelled += (transform.forward * Time.deltaTime).magnitude + (transform.right * Time.deltaTime).magnitude;
And do a simple if on that distanceTravelled to know when to stop.
Alternatively, if you just want smooth movement, I like to use Lerp SMOOTH with LERP! (Move, Rotate, Float) shorts - Code Monkey
Is there any way to measure the rotation y value like transform.forward?
@CodeMonkeyYT