- Home /
Possible to make rigidbody immovable without "Is Kinematic"?
I have a bunch of AI actors chasing my player, and when they get within attack distance, they stop. However, when there are actors behind the stopped actors, they push the stopped actors closer.
If I use Is Kinematic, they phase through each other, this is not something I want.
So how can I make the stopped actors immovable to the other actors pushing shenanigans? I tried hard-setting the rigidbody velocity to Vector3.zero during the stopped state, but that didn't work either.
Have you tried setting the rigidbody's weight to something extremely high relative to your scene? That might make them effectively immobile, and force your other actors to move around it. I'm having a little trouble envision what you are talking about, a screenshot might help.
Answer by PrimeDerektive · Feb 03, 2011 at 01:01 AM
Instead of trying to make the rigidbody immovable, i decided to do some simple neighbor avoidance by using Physics.Overlapsphere and applying force in the direction opposite the neighbor. It works pretty well, feel free to crib:
function FixedUpdate(){
var neighbors : Collider[] = Physics.OverlapSphere(transform.position, 1.5);
for(var neighbor : Collider in neighbors){
if(neighbor.CompareTag("Enemy") || neighbor.CompareTag("Player")){
var neighborDir = (transform.position - neighbor.transform.position).normalized;
rigidbody.AddForce(neighborDir*25);
}
}
}
Answer by synapsemassage · Feb 20, 2011 at 12:39 PM
You could spawn a simple static gameobject with a simple collider at the position of your stopped actors while also making your actor kinematic. And destroy the simple GO when actors start to move again or GO is not needed?! Or just constrain it in the Constraints section of the rigidbody component.
Answer by Lo-Rez Games · Mar 04, 2014 at 05:24 AM
Yes. Set the mass of the object you don't want to move REALLY high.
Your answer
Follow this Question
Related Questions
Rigidbodies won't collide if mass difference is too high 0 Answers
Get a bounding sphere for collider/rigidbody? 0 Answers
OnCollisionEnter isnt called when player lands on object 1 Answer
How can i Prevent Kinematic object not to pass through another rigidbody object 1 Answer
Best way for rigidbody enemy? 1 Answer