- Home /
Var CollisionObject not working.
I want to select my collision object in the inspector so it would be easier.
This is the script I attached to my Capsule.
public var animationName : String;
public var collisionObject : GameObject;
function OnCollisionEnter(theCollision : Collision){
if(theCollision.gameObject.name == collisionObject){
animation.Play(animationName); }
}
Why isn't my animation playing when colliding? It does work when I fill in the collision object by hand.
Answer by scarletsnake · Apr 04, 2012 at 10:28 PM
Have you tried using triggers? I'm not sure if that would help but I always use them instead of collision codes, had a lot of problem with the OnCollisionEnter code when working with projectiles. Now I'm only using triggers and raycasting, they work perfectly fine.
Your answer
![](https://koobas.hobune.stream/wayback/20220613065920im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Fast moving object passing through other objects. 6 Answers
Making an object a child on collision 1 Answer
colliding with 2 objects at a time 1 Answer
Objects Touching? 1 Answer
How to check which colliders that collision with some object ? 3 Answers