Skip to main content
Tweeted twitter.com/#!/StackGameDev/status/471964735747792897
code formatting. GIF into example link.
Source Link
bummzack
  • 22.7k
  • 5
  • 64
  • 87

I have a player that shoots in the direction that it is facing. However, the shot that is created when I click, also destroys the player (example). How would I make the shot ignore collision with the player? Or better yet, how to make a shot destroy anything it touches and destroy itself without affecting the player?

This is the code that controls collisions: function OnTriggerEnter (col : Collider) { Destroy(col.gameObject); }

function OnTriggerEnter (col : Collider) { Destroy(col.gameObject); } 

The shot is a trigger, but the player isn't. Not sure if this changes anything in this case.

Thanks in advance.

EDIT: http://gfycat.com/TediousAridFeline

I have a player that shoots in the direction that it is facing. However, the shot that is created when I click, also destroys the player. How would I make the shot ignore collision with the player? Or better yet, how to make a shot destroy anything it touches and destroy itself without affecting the player?

This is the code that controls collisions: function OnTriggerEnter (col : Collider) { Destroy(col.gameObject); }

The shot is a trigger, but the player isn't. Not sure if this changes anything in this case.

Thanks in advance.

EDIT: http://gfycat.com/TediousAridFeline

I have a player that shoots in the direction that it is facing. However, the shot that is created when I click, also destroys the player (example). How would I make the shot ignore collision with the player? Or better yet, how to make a shot destroy anything it touches and destroy itself without affecting the player?

This is the code that controls collisions:

function OnTriggerEnter (col : Collider) { Destroy(col.gameObject); } 

The shot is a trigger, but the player isn't. Not sure if this changes anything in this case.

added 45 characters in body
Source Link
eren_tetik
  • 451
  • 1
  • 8
  • 17

I have a player that shoots in the direction that it is facing. However, the shot that is created when I click, also destroys the player. How would I make the shot ignore collision with the player? Or better yet, how to make a shot destroy anything it touches and destroy itself without affecting the player?

This is the code that controls collisions code: function OnTriggerEnter (col : Collider) { Destroy(col.gameObject); }

The shot is a trigger, but the player isn't. Not sure if this changes anything in this case.

Thanks in advance.

EDIT: http://gfycat.com/TediousAridFeline

I have a player that shoots in the direction that it is facing. However, the shot that is created when I click, also destroys the player. How would I make the shot ignore collision with the player? Or better yet, how to make a shot destroy anything it touches and destroy itself without affecting the player?

This is the code that controls collisions code: function OnTriggerEnter (col : Collider) { Destroy(col.gameObject); }

The shot is a trigger, but the player isn't. Not sure if this changes anything in this case.

Thanks in advance.

I have a player that shoots in the direction that it is facing. However, the shot that is created when I click, also destroys the player. How would I make the shot ignore collision with the player? Or better yet, how to make a shot destroy anything it touches and destroy itself without affecting the player?

This is the code that controls collisions: function OnTriggerEnter (col : Collider) { Destroy(col.gameObject); }

The shot is a trigger, but the player isn't. Not sure if this changes anything in this case.

Thanks in advance.

EDIT: http://gfycat.com/TediousAridFeline

Source Link
eren_tetik
  • 451
  • 1
  • 8
  • 17

How to ignore collision between two objects

I have a player that shoots in the direction that it is facing. However, the shot that is created when I click, also destroys the player. How would I make the shot ignore collision with the player? Or better yet, how to make a shot destroy anything it touches and destroy itself without affecting the player?

This is the code that controls collisions code: function OnTriggerEnter (col : Collider) { Destroy(col.gameObject); }

The shot is a trigger, but the player isn't. Not sure if this changes anything in this case.

Thanks in advance.