- Home /
Transform position over X amount of time , how ?? c#
so i have my character move in a straight line but i want him to stop after 4 seconds . i have failed at trying to do this ( -)
transform.position += transform.forward 5.0f Time.deltaTime;
Answer by Screenhog · Sep 05, 2012 at 09:58 PM
Have you seen iTween yet? It's on the Asset Store, it's free, and it's simple to use. Your code would look like this (you just have to give it a position):
iTween.MoveTo(gameObject, myPosition, 4.0);
Although, in your case, iTween.MoveBy might be more useful.
If you insist on changing the transform.position yourself, one way to do that would be to add a Vector3.Lerp.
wow iTween is very good screenhog
i added the script but it now displays an error saying
`UnityEngine.GameObject' does not contain a definition for `iTween' and no extension method `iTween' of type `UnityEngine.GameObject' could be found (are you missing a using directive or an assembly reference?)
You've added the iTween script to your project, right? What is the line of code you've written to move your object with iTween?
well it seems that the problem was not iTween itself but the silly structure of the C# script that i have to run it in . i am unable to run iTween functions in that area of coding =[
Answer by moinchdog · Sep 18, 2012 at 12:50 AM
google transform.Translate or Vector3.Lerp
it will help
Dj
Your answer
![](https://koobas.hobune.stream/wayback/20220613080657im_/https://answers.unity.com/themes/thub/images/avi.jpg)