x


Making an object bounce back? perhaps Javascript?

I am making a fps game where a knife is supposed to fly on the x axis. When it hits the wall, I want it to switch directions and fly back on the negative x axis. I think it's a code. I think it should have a function update, and it rotates exactly 180 degrees and it switches to the other direction when it collides with a box collider. Please help! and PS. Please write which script type it is. Thanks!

more ▼

asked Aug 05, 2010 at 09:57 PM

Not showing my name gravatar image

Not showing my name
117 24 18 27

Don't expect people to code for you. Try to script some stuff yourself and ask for corrections and such. Sometimes if you have no idea you can ask without other info but generally try to script some yourself.

Aug 05, 2010 at 10:48 PM MikezNesh

A short answer: (put in comments because its not complete)

Based on the fact that you have read the fps tutorial (got info from your previous posts) you seem to know about the rigidbody.velocity well now all you got to do is:

OnCollisionEnter {rigidbody.velocity = -X} Note: this is not in code just logic

Where X is equal to the speed you want it to fly back at..

Aug 05, 2010 at 10:55 PM MikezNesh
Aug 05, 2010 at 10:58 PM qJake
(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
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:

x4017
x192
x39
x36

asked: Aug 05, 2010 at 09:57 PM

Seen: 3610 times

Last Updated: Oct 31, 2010 at 07:27 PM