- Home /
Player Pushes Enemies. (That's bad) -Still Unanswered-
So, I have some rigidbody enemies. They use a rigidbody.MovePosition to move.
The problem is this, when the character runs into the players, the velocity from the character is transferred to the enemy (think newton's cradle). I don't want this. Is there a way to ignore physics from the player? I don't want to be able to walk through the enemies. I want them to solid when I hit them, and stand their ground.
Does that make sense?
EDIT:
So the problem has changed a little bit after a lot of digging! It has something to do with my scripts (links found in comments). I use a Move function to move the enemy, and I put a velocityX variable into the move to move my enemy. When I set velocityX to 0 and the enemy is still, then the enemy doesn't get pushed around, but when the enemy is moving, the enemy gets pushed around. I need ideas!
EDIT 2:
I changed to a AddForce function, but it still hasn't helped! I made a video of the problem to try and better explain it: Link to Video!
EDIT 3:
I'm back again... I totally rewrote the script. I took everything to the dry erase board and wrote it all out before I typed it up. The pushing problem still persists though. I can't figure out what's going wrong!!! Any ideas? (If you want, my skype is cg.artist4jc. If you contact request me, please put "Unity" in the contact request message.)
|-------------- LINK TO SCRIPT --------------|
Can you not simply un-check the 'Animate Physics' Box?
I tried checking Animate Physics on my Character's animation component. Didn't help. But thanks for the suggestion!
Any other ideas?
It's supposed to be un-checked... but I guess it was to begin with :/
That's the box that tells Unity to push objects around with animated limbs etc. Are you trying to use Character controller on enemy too?
Only other suggestions are,
Increase enemy mass
OR
Remove Player/Enemy correlation from Collision $$anonymous$$atrix; Project Settings -> Physics
EDIT: Damn just noticed your 'I dont want them to walk through' comment :P
Which $$anonymous$$ove function do you use?
Answer by aldonaletto · Sep 05, 2013 at 02:57 AM
If you set the player mass to a value much smaller than the enemies, they will barely move when hit by the player. Another possible solution would be to freeze position and rotation in all axes in the Constraints field of the enemies: this would eliminate physics reactions to collisions, but you still would be able to directly move the rigidbodies. Finally: use a CharacterController instead of a rigidbody in the player - a CharacterController is constrained by any collider, but won't push rigidbodies.
HINT: You may let Freeze Position Y unchecked in order to preserve gravity effects. This usually works fine when the enemies have box colliders, but may make them jump if their colliders are spheres or capsules: when hit at a point below the "equatorial line", the resulting impact has +Y components that may push the rigidbody up.
Ok, the mass thing didn't work at all. And if I freeze all the axises (axi?) then the player can just walk through the rigidbody. It will detect collision, but not stop. And my player does have a Character Controller, but the enemies have rigidbody controllers.
Any other ideas? I just want the enemies to ignore any physics from the character. So any inertia or conservation of energy is ignored.
when you changed the mass of either the difference needs to be a factor of about 100x to stop the interaction in the direction of the bigger thing.
The player already is a CharacterController? It should be stopped by any collider, if moved with $$anonymous$$ove or Simple$$anonymous$$ove - don't use Translate or modify its position directly!