I'm trying to make a crane game and using rotation failed horribly with clipping so I'm not using pre-canned animations. My plan is that upon contact with a prize, the animation stops in place. That way you never quite get a full grip on the item you are trying to carry. Unfortunately the animations do not stop. It goes to where it has to go but nothing else. It doesn't even say the debug line for when it stops. The colliders don;t seem to understand that they connected, but I can grip the objects and lift them, so they ARE colliding. PHP: #pragma strictvar animatePhysics : boolean;var i : int;function Start () { animation.Play ("Open"); animation.wrapMode = WrapMode.Clamp; i = 0;}function Update (){ if (Input.GetKeyDown ("space")) { playanimation(); }}function playanimation(){ i ++; if (i % 2 == 1){ animation.Play ("Close"); } else if (i % 2 == 0){ animation.Play ("Open"); }}function OnCollisionEnter (col : Collision){ if(col.gameObject.tag == "Prize"){ animation.Stop(); Debug.Log("should stop"); } if(col.gameObject.tag == "Release"){ animation.Play ("Open"); Debug.Log("should open"); }} Any idea why this is happening?
Because you did the collision wrong if I am correct. Try this instead of animation.play . Animation.play (Open) Animation.close on animation.player. enjoy I may have put one error just put the sl in and it should fix it.
He means you need to use the right command. animation.play does nothing. Animation.play is what you're after. capitalised first letters in functions and classes, small in variables.
Animation doesn't have a "play" variable. Do you have non-kinematic rigidbodies attached to your prizes, and kinematics attached to your claws? That should set you up to register collisions. Try debug.logging in OnCollisionEnter, at the very start, to see if the claw connects at all. It's possible the tags are incorrect, or one or more objects are mis-tagged.
Yeah, I have non-kinematic bodies. (why should the claw be kinematic? If I do that it just goes through everything. The prizes are tagged and layered Prize. I don't have a release cube yet. But yeah, I debugged on collision. heck, I made it so it it destroys itself if it touches anything. It touches stuff. It stops. But it does not destroy. I also tried a print statement and it does nothing as well. It connects but doesn't register that it connects.
I have no idea what a break point is. This is my current code. PHP: #pragma strictvar animatePhysics : boolean;var i : int;var speed : float;function Start () { animation.Play ("Open"); animation["Open"].speed = 1.0; animation.wrapMode = WrapMode.Clamp; i = 0;}function Update (){ if (Input.GetMouseButtonDown (0)) { playanimation(); }}function playanimation(){ i ++; if (i % 2 == 1){ animation.Play ("Close"); animation["Close"].speed = 1.0; } else if (i % 2 == 0){ animation.Play ("Open"); animation["Open"].speed = 1.0; }}function OnCollisionEnter (){ //if(col.gameObject.tag == "Prize"){ animation["Close"].speed = 0.0; Debug.Log("should stop");// } } I'm just trying to pause an animation on the frame it makes contact. I've tried capitalizing the A but it keeps giving me errors saying Animation is not a real thing. Theoretically, changing the animation speed to zero should and then switch it back to 1 each click should work. But it doesn't.