- Home /
Transform.Translate Does not work correctly
I do not understand what the problem is. Cube. Start position: (6.75, 1.5, 18.875). If y>=2 - it work Not set rigidbody.
var moveSpeed : float = 0.1;
function Update () {
translation = Time.deltaTime * moveSpeed;
transform.Translate(new Vector3(1.8,1,13.9) * translation);//The problem in this line
}
Motion map
transform.Translate(new Vector3(1.8,1,13.9) * translation);-move
transform.Translate(new Vector3(1.8,1,-13.9) * translation);-move
transform.Translate(new Vector3(1.8,-1,13.9) * translation);-move
transform.Translate(new Vector3(1.8,-1,-13.9) * translation);-move
transform.Translate(new Vector3(-1.8,1,13.9) * translation);-move
transform.Translate(new Vector3(-1.8,1,-13.9) * translation);-not move
transform.Translate(new Vector3(-1.8,-1,13.9) * translation);-move
transform.Translate(new Vector3(-1.8,-1,-13.9) * translation);-not move
It is unclear here what you are looking at in terms of expected behavior. Assu$$anonymous$$g this is the only movement script on the block, it will will use Vector3(1.8,1,13.9) as the direction vector for movement, and it will move in that direction at the rate of 0.1 units per second. Note the code above will not compile because 'translation' is not declared.
I [First Person Controller+$$anonymous$$ouseLook+Character$$anonymous$$otor+FPSInputController, position(1,2,1), scale(1,1,1), height=0.5] look at the expected behavior, standing on a stationary cube position(1,1.5,1), scale(2,0.25,3).
This is the only movement script on the block.
$$anonymous$$ore a function start (), but it's empty.
function Start () {
}
Well there is nothing in this script that would have inconsistent behavior...that is it would not change it behavior just because y >= 2. Something else is impacting this cube...a collision for example or another script.
@robertbu, Sorry for nitpicking but it won't move at the rate of 0.1
units per second. It will move at the ever so weird 0.1*sqrt(197.45) u/s
approximately equivalent to 1.406 u/s
:P
@igorshemi It would be beneficial both to yourself and anyone else reading your code if those vector values were explained in a comment.
Answer by igorshemi · Feb 09, 2014 at 11:56 AM
Sorry. Found a bug: the old project used as the template. Although itself a mistake and did not find, but in pure project - everything works as expected.
Topic can be closed
Your answer
![](https://koobas.hobune.stream/wayback/20220613132844im_/https://answers.unity.com/themes/thub/images/avi.jpg)