x


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.

more ▼

asked Feb 07 '10 at 09:09 PM

andy_the_baker gravatar image

andy_the_baker
1 1 2 3

(comments are locked)
10|3000 characters needed characters left

2 answers: sort oldest
more ▼

answered Feb 08 '10 at 10:54 AM

runevision gravatar image

runevision ♦♦
8.1k 29 46 112

thanks for these links.

Feb 17 '10 at 06:12 AM andy_the_baker
(comments are locked)
10|3000 characters needed characters left

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... :-)

more ▼

answered Feb 08 '10 at 05:26 AM

Jaap Kreijkamp gravatar image

Jaap Kreijkamp
6.4k 20 26 70

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 timing. it was helpful.

Feb 17 '10 at 06:14 AM andy_the_baker
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x984
x804
x263
x116
x25

asked: Feb 07 '10 at 09:09 PM

Seen: 3057 times

Last Updated: Feb 07 '10 at 09:09 PM