x


Cover mechanic - Restrict movement to box

I'm trying to create a simple cover mechanic by using box colliders and checking for trigger events. As with all cover mechanics, I want to ensure that the player can not leave the bounds dictated by the box collider.

How would I go about ensuring the player (in this instance a character controller) does not leave the box colliders individual bounds?

more ▼

asked Jul 25 '10 at 08:07 PM

Disaster gravatar image

Disaster
482 48 57 67

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

1 answer: sort voted first

There shouldn't be a problem. Character controllers do respond to collisions, otherwise they'd fall through floors and walk through walls.

If your colliders are set up correctly and are not simply triggers, the the character controller shouldn't move through them.

If they need to be triggers for some reason, though I'm not sure why that would be, you will have to write code that responds to the trigger by moving the player back to a spot inside the box. (Maybe the last spot they were at before the collision occurred.)

more ▼

answered Jul 28 '10 at 07:52 PM

Bampf gravatar image

Bampf
5k 8 19 49

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

x5088
x2503
x1705

asked: Jul 25 '10 at 08:07 PM

Seen: 1256 times

Last Updated: Jul 25 '10 at 08:07 PM