- Home /
Moving player in an arc, from startPoint to endPoint
hi.
fairly new to unity, with some minor experience in programming.
i've set up a trigger region (the start point), which contains a target (transform) that i'm trying to toss the player character to (like a catapult).
i've tried using this setup but it doesn't work for me:
http://unity3d.com/support/documentation/ScriptReference/Vector3.Slerp.html
i've also tried a series of Vector3.Lerps, but don't think that's the smartest way to go about it.
also: i cannot for the life of me get this to play out for longer than a second, no matter what i multiply Time.time or Time.deltaTime with (from .0000001 to 1000000). do i need to move this function outside of function Update?
any help would be greatly appreciated. i've been stuck for about a week! :) thanks.
Answer by runevision · Feb 08, 2010 at 10:54 AM
See this these questions for multiple solutions:
Answer by Jaap Kreijkamp · Feb 08, 2010 at 05:26 AM
The third parameter of Slerp is clamped between 0 and 1 (so it will never exceed these values). So in your case you would probably use something like:
transform.position = Vector3.Slerp(riseRelCenter, setRelCenter, (Time.time - startTime) / duration);
Where startTime
is a variable that contains the time you begin the arcmovement (so set this to Time.time
when the player starts this move and duration
must hold the total time it should take to make the 'jump'.
Hope this helps... :-)
you know what the problem was? i was declaring and reassigning the variables constantly. it was arcing but at the end it was slow because it was slerping between smaller and smaller positions. taking the start/end out of the loop was the solution. thanks for your help in understanding the ti$$anonymous$$g. it was helpful.
Yeah i know its pretty old post but may be for people who are looking for this kind of mechanics , This $$anonymous$$ay Helps
Your answer
Follow this Question
Related Questions
How you change another script value smoothly on trigger 0 Answers
Moving the player toward a direction 1 Answer
Move object in an arc 3 Answers
Player carries all boxes instead of one when lifting a box 0 Answers
I'm not using Lerp properly 1 Answer