- Home /
iTween help needed
Hi
Im very new at scripting in Unity / iTween. Im currently using Javascript and im trying to get this to work:
var LandingZone = GameObject.Find("LandingZone");
function Start ()
{
iTween.MoveTo(GameObject, {"position": Vector3(LandingZone.transform.position.x, 0.5, LandingZone.transform.position.z), "time":10, "easetype": iTween.EaseType.linear});
}
I'm trying to move an instantiated object to the "LandingZone" So far i can assign a script to the object, but can't figure out how to get the object to move to the landing zone.
any help will be greatly appreciated. thanks Sam
Answer by DracoScorpius · Apr 02, 2012 at 10:14 PM
var CatchSpeed = 50.0;
function Update ()
{
// Follows the target position like with a spring
transform.position = Vector3.MoveTowards(transform.position, LandingZone.transform.position, Time.deltaTime * CatchSpeed);
}
You can change the CatchSpeed to change how quickly the object moves. I'm sorry if this doesn't work exactly, having had no experience with iTween yet, but you should be able to manipulate this to your bidding.
Answer by sam-luk · Apr 04, 2012 at 12:19 AM
hey thanks for the reply,
i couldn't quite get your method working, but i did manage to fix it using iTween:
iTween.MoveTo(gameObject, {"position": Vector3(LandingZone.transform.position.x, 0.5, LandingZone.transform.position.z), "time":10, "easetype": iTween.EaseType.linear});
I think my major problem was not finding "LandingZone" correctly. i didn't define it as a gameObject and that's why it wasn't working.
but thanks
Sam
for " i didn't define it as a gameObject and that's why it wasn't working." >< thats my problem as well. Thanks! (I didn't have permission to vote up your answer yet :D)
Your answer
![](https://koobas.hobune.stream/wayback/20220613065820im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to Parent a Cloned Object to Another Cloned Object 1 Answer
Instantiate Clones Itself - Rather than Prefab 0 Answers
Destroy a specific instantiated clone? 2 Answers
orienttopath problem in iTween waypoint ? 0 Answers
Instantiate Reference Problem 1 Answer