x


If trigger hit, spawn it

Hi All Guys! nice to meet you from the net.

I am trying to make a easy game which is if a ball(TAG AS PLAYER) hit the pipe(TAG AS ENEMY), it will return to the stating point.

The pipe have collider component and the ball also. Should I need to tick the trigger box?

How can I write the script in C# about that? I am quite confused about that, plz help me.

more ▼

asked Apr 19 '12 at 03:18 PM

Wesker_Kai gravatar image

Wesker_Kai
3 4 5 5

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

1 answer: sort voted first
function OnCollisionEnter(other:Collision){
   if(other.gameObject.tag=="enemy"){
       transform.position=Vector3(0,0,0);}}

Attach that to the player. That consider that 0,0,0 is the origin of your game.

IsTrigger means you want to ignore physics meaning that the object won't bounce. In your case that won't change much since you are respawning your guy.

more ▼

answered Apr 19 '12 at 04:00 PM

fafase gravatar image

fafase
10.5k 9 15 40

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

x5070
x2486
x1866
x982
x183

asked: Apr 19 '12 at 03:18 PM

Seen: 796 times

Last Updated: Apr 19 '12 at 04:00 PM