- Home /
transform.position not moving object
hi,
i have car object and I am trying to move it below code in update method:
car1.transform.localPosition -= Vector3.up * Time.deltaTime *10;
i also tried position
instead of localPosition
but nothing changed. I don't understand why its happens because in the another script same code is working as expected. Do you have any idea why it doesn't work?
Thanks
Also just a tip. You need to give people more information because this isnt enough information on its own to give you any sensible answers. It could be a million and one reasons. That said:
https://www.youtube.com/watch?v=njATNVV$$anonymous$$ScY&feature=youtu.be
This shows the assumed use
Answer by k234234w · Aug 09, 2019 at 06:15 PM
Can we see your full script. If the object is marked static, or if your Timescale is 0 it will not move.
@k234234w yes accidentally I marked it as static. thanks.
please, please, please learn what the code you are writing means, At the very least learn one thing: What the static keyword means.
I see so many people using it on almost all their members. You should rarely see it.
I am assu$$anonymous$$g he marked the game object as static, not the class. Those are different things. https://docs.unity3d.com/$$anonymous$$anual/StaticObjects.html
Answer by I_Am_Err00r · Aug 09, 2019 at 06:18 PM
car1.transform.Translate(Vector3.up * 10 * Time.deltaTime);
I think that's what you are looking for, but I'm not too sure because you have a -= and then Vector3.up, so it might Vector3.down you are looking for, I'm not sure what you are trying to do as the other comments are saying.