x


A question about terrain collision

Hi again, another noob question from yours truly...

I am making a "Mode7" styled racing game... for the off-track area and boundary collision, I am using terrains (invisible to the player). The problem I have, is for the boundary terrain collision, if I set it to a trigger (to activate damage/play crash sound etc) the car drives through it... I know this is how triggers work, as it detects when one object intersects with another, so the workaround I have done is used two identical terrains, one as a trigger, the other to act as a solid object, to stop the car. Is this the way to go? Doubling up on terrains seems a bit overkill for me... I don't have any performance issues, the game runs perfectly on even older hardware (although I have yet to try out on iOS), but I would like to know if there is a better way, for optimisation's sake :)

Cheers!

more ▼

asked Jun 14 '12 at 09:41 PM

POLYGAMe gravatar image

POLYGAMe
434 37 46 53

You weren't getting OnCollisionEnter when it wasnt a trigger?

Jun 14 '12 at 09:53 PM whydoidoit

No... is that odd? I thought that was normal...

Jun 14 '12 at 11:34 PM POLYGAMe

You should get an OnCollisionEnter I thought - hey I'm no expert with terrains and collision, but I can't see why you wouldn't.

Jun 14 '12 at 11:37 PM whydoidoit

Well you won't get an OnTriggerEnter if it isn't a trigger - but you will get an OnCollisionEnter (which takes a Collision as a parameter not a Collider).

Jun 15 '12 at 12:19 AM whydoidoit

Posted it as an answer so future generations won't need to read a lot of comments...

Jun 15 '12 at 12:42 AM whydoidoit
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Use a single terrain, not a trigger and check OnCollisionEnter rather than OnTriggerEnter.

more ▼

answered Jun 15 '12 at 12:41 AM

whydoidoit gravatar image

whydoidoit
33.1k 12 23 101

Works like a charm. Can't believe I was doing that! LOL. Noob...

Jun 15 '12 at 12:53 AM POLYGAMe
(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:

x2504
x472
x101
x29
x12

asked: Jun 14 '12 at 09:41 PM

Seen: 808 times

Last Updated: Jun 15 '12 at 12:53 AM