x


Wall Jump and loops

Ok two questions,

Is there any while loops, or something similar, so i can do certain things while in a specific state? For example for the wall jump i want to say

// while(touching wall) { Pause for a second then drift slowly down }

otherwise gravity is normal //

But anything I try the character will drift slowly down after touching the wall then moving to the side and not actually being on the wall.

Second question. If i want him to jump off the wall, if there a better way then changing the horizontal velocity? I only want him to move about 5-10 'units' away from the way then hold normal horizontal velocity.

more ▼

asked Jun 21 '11 at 05:05 AM

jlimbach gravatar image

jlimbach
11 5 7 8

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

4 answers: sort voted first

for your first question, you want to use a coroutine.

for your second question, you want to interpolate from one position to the other using Mathf.SmoothDamp.

more ▼

answered Jun 21 '11 at 05:11 AM

testure gravatar image

testure
4.2k 20 25 48

(comments are locked)
10|3000 characters needed characters left
  1. Either store your states in an Enum type variable or assign a toggle variable for each state.
  2. You can clamp the horizontal component of the velocity after a specified condition is fulfilled.
more ▼

answered Jun 21 '11 at 05:25 AM

Dreamblur gravatar image

Dreamblur
703 9 16 22

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

I suppose my greatest question is how does Mathf.SmoothDamp work? I looked it up but cant figure it out http://unity3d.com/support/documentation/ScriptReference/Mathf.SmoothDamp.html

more ▼

answered Jun 22 '11 at 03:23 PM

jlimbach gravatar image

jlimbach
11 5 7 8

don't post questions or comments as answers. use the 'add new comment button'. It screws up the ordering of posts, and it doesn't read linearly. not to mention it messes up search results.

SmoothDamp eases one value to another at a specified speed. It requires a reference to a velocity variable so in order to make it happen. There's not really more to tell, that's all it does.

Jun 22 '11 at 03:26 PM testure
(comments are locked)
10|3000 characters needed characters left

mathf.smoothdamp looks goood, but I cant seem to figure out how to make it work. Does that just keep returning a value that i set to his x position?

more ▼

answered Jun 22 '11 at 03:10 PM

jlimbach gravatar image

jlimbach
11 5 7 8

(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:

x4

asked: Jun 21 '11 at 05:05 AM

Seen: 610 times

Last Updated: Jun 22 '11 at 03:26 PM