#help me
1 messages · Page 1 of 1 (latest)
Where's point 4?
Also, you're using translate wrong. Have a read of the function in the docs. Specifically what it does and how the parameter that it takes affect it.
I have already read it
I have also used transform.translate before but it was all using a normalized vector
Do you understand the difference between position and direction?
so it has to be normalized?
but why can't the vector 3 be a direction?
or should I use rb.MovePosition();
@mellow acorn
it does move to the point in my other experiences
or maybe you can tell me what's wrong and how to fix it
It can.
Position is also a direction. A direction from the world origin to the target position.
So translate is moving towards direction. what you want is just change position and use something like
transform.position = Vector3.Lerp()
what does that Lerp method do?
so vector3.distance?
Lerp changes position from one to another smoothly
so it's like translate but it moves towards a vector3
you will see it moving smoothly. Lerp is linear transformation, also there are slerp and etc
wait......
can I pass in a transform in transform.Translate?
like transform.Translate(transform * speed * Time.deltaTime);
If you want move dot from point A to point B, then you need to use lerp.
https://docs.unity3d.com/ScriptReference/Vector3.Lerp.html
If you want to make object to move specific direction for specific amount of time, you use Translate.
I don't want it to teleport,I just want it to move towards it
Lerp does eactly what you want.
that's why I added * Time.deltaTime
ok
transform.position = Vector3.Lerp(startMarker.position, endMarker.position, fractionOfJourney);
this example eplains it best. you give start position, end position, and time in which you want that object to reach the final position. so it will not be teleportation.
is there any way that I can use transform.Translate ?
What are you actually trying to do? Move towards another position at a speed?