- Home /
Colliders in if statement
I'm trying to make an arm grab the ground. I did this by creating a separate collider on top of the ground so it can act as a trigger without my character falling through the real ground.
As of now I'm just using a basic script that freezes the "hand" anywhere in the gamespace.
function Update() {
if(Input.GetKey(KeyCode.Space))
{rigidbody.isKinematic = true;}
else
{rigidbody.isKinematic = false;}
}
How can I make it only go kinematic when it's inside the collider? the collider is called 'ground'. I've tried doing it myself but my I just started to learn javascript. Any help is appreciated.
Thanks!
Answer by Anxo · Oct 24, 2011 at 03:02 PM
You can tell colliders to ignore other colliders, search the docs for "ignore collision" or you can turn the arm into a trigger and just say
OnTriggerEnter..... then have an if(other.CompareTag("ground")...
Your answer
![](https://koobas.hobune.stream/wayback/20220613021218im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Go kinematic when in collider 1 Answer
How to block dragging if collider hits 1 Answer
Bouncing a rigidbody on a rigidbody 0 Answers
Trigger Enter and Exit not working properly? 2 Answers
Object push character controller 2 Answers