- Home /
Ethereal Character Controller
Hi!
I have several AI driven characters that when moving keeps colliding with each other. How can I do to avoid this?
I am trying to acces the Rigidbody in the Character Controller component in order to set the IsKinematic property to true, but is not working. Is this the way to go? Is there a better solution? Why do I receive null when calling:
GetComponent().attachedRigidbody;
Thank you!
try gameObject.GetComponent(Rigidbody);
or gameObject.GetComponent("Rigidbody");
Thanks, I tried it but it is still nto working. I get NullReferenceException. I am using C#, so I tried this without success:
gameObject.GetComponent().is$$anonymous$$inematic = true;
There is no Rigidbody on the GameObject. The Rigidbody is provided by the Character Controller, which inherits form Collider. Will really setting the GameObject to is$$anonymous$$inematic solve do what I want?
Answer by asafsitner · Sep 13, 2012 at 06:48 AM
You can access the rigidbody component directly via `transform.rigidbody`
I presume you're using Unity free, because if you're using pro you would probably do better using the built-in `NavMesh` and `NavMeshAgent`.
Another possible approach to your problem that will solve collision between AI agents but still allow them to collide with the environment is to set them on a physics layer of their own and then set the collision matrix so that this layer won't collide with itself.
Thanks, I tried accesing transform.rigidbody directly: doesn't work. There is no Rigidbody on the GameObject. The Rigidbody is provided by the Character Controller, which inherits form Collider.
You are right, I am using Unity Free. How does the Nav$$anonymous$$esh works? What are they useful for?
But....YES! The layer trick solved it!!! Had no idea about this feature, I am learning. Awesome! Solution was only uncheking a checkbox...After 3-4 hours messing around!
Thank you asafsitner!
Always happy to help ^^
You can accept the answer so it won't appear on the question queue by clicking the tick on the left, below the vote options.
Nav$$anonymous$$esh is a solution for path-finding, built into Unity pro.
Sure, I tried to do it, but I messed up. I wrote my answer as a new answer and sent it without noticing. A message came up saying that ad$$anonymous$$istrators where going to review the answer. I guess I will be able to do it when reviewed. Right know it says:
We're sorry, but this question already has an accepted answer. Please remove the accepted status from the other answer first.
Answer by Sueko · Sep 13, 2012 at 11:46 AM
Thanks, I tried accesing transform.rigidbody directly: doesn't work. There is no Rigidbody on the GameObject. The Rigidbody is provided by the Character Controller, which inherits form Collider.
You are right, I am using Unity Free. How does the NavMesh works? What are they useful for?
But....YES! The layer trick solved it!!! Had no idea about this feature, I am learning. Awesome! Solution was only uncheking a checkbox...After 3-4 hours messing around!
Thank you asafsitner!
Your answer
Follow this Question
Related Questions
Activate physics when animation ends 0 Answers
Ragdoll driven game 1 Answer
Cannot register Collision from behind. 0 Answers
How to setup character Collisions? 2 Answers
Fps Ladder script... 1 Answer