x


Rigidbody collision/interaction

What I am trying to do is simply allow for the interaction between player (FPSController) and a barrel mesh I have created.

I stack the barrels up and then the player can walk into them, interacting and colliding with the barrels, knocking them over.

I have applied rigidbody colliders and mesh collision to the barrels and they fall and hit each other but they aren't actually effected by the player, though he does collide with them, just no movement.

I have not a clue how to go about doing this and any help would be greatly appreciated.

more ▼

asked Nov 12 '11 at 03:52 AM

Sitrane gravatar image

Sitrane
16 8 10 12

What is your player? Is the player another rigidbody, or is it a CharacterController or a static collider using transform.Translate for movement?

Nov 12 '11 at 04:13 AM syclamoth
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

What is your player? Is the player another rigidbody, or is it a CharacterController or a static collider using transform.Translate for movement? Static colliders won't cut it here- you should at least use a kinematic Rigidbody here. The best way is to make the player a non-kinematic rigidbody (preforably with freezeRotation on so that you don't roll everywhere) so that it can interact with other rigidbodies properly.

more ▼

answered Nov 12 '11 at 04:15 AM

syclamoth gravatar image

syclamoth
14.8k 7 15 80

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

FPScontroller is the one that uses controller.Move(moveDirection) using a charController, right? CharConts purposely do not push or even hit other objects. They sort of see that they would hit something, not in the physics engine, and slide around before technically colliding.

The special http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.OnControllerColliderHit.html was created for this. That page has an example of how to "build" a push. Since it's code, you can tweak/redo it all you like (for example, to push away from you instead of directly forwards.)

more ▼

answered Nov 12 '11 at 03:21 PM

Owen Reynolds gravatar image

Owen Reynolds
11.6k 1 7 45

All this messing around is why I don't use CharacterControllers. They're useful for exactly one thing, and if you want to do anything else with them it's much quicker and easier to write your own...

Nov 13 '11 at 04:45 AM syclamoth

Thank you Owen! This was EXACTLY what I needed!

Nov 13 '11 at 09:11 PM Sitrane
(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:

x2506
x1798
x809
x45

asked: Nov 12 '11 at 03:52 AM

Seen: 1214 times

Last Updated: Nov 13 '11 at 09:11 PM