Hi guys please help I tried everything I know spent hours no luck.
I have Gameobject/image and want to play a animation on collision on it but nothing is working
I tried tons of combos and options. I have a small question…If you drag an image onto scene is that considered a gameobject?- maybe that the problem??
But I added rigigbodies 2d 2d colliders 2d oncollision on trigger ect etc I checked a lot of basics And tried a lot of scripts from references area
Nothing happens on any collision I set trigger to gameobject.
I see animation playing rapidly but will not play on collision at all. But animation is working when reviewed in animation inspector area
Anyway
I currently have this (javascript)
function OnCollisionEnter2D(Collider2D) {
if(gameObject.tag == "Player")
{
animation.Play("crack");
}
}
I also tried OnTriggerEnter 2d etc scripts & more
I added this to game object but nothing happens
the animation keeps playing constantly with things I did in animator controller.
I tried looking at animator controller animations
scripts still nothing.
My animation just keeps playing from the botched( I think botched) parameter I put thru animator controller
I did add this to correct gameobject and tagged other gameobject correctly as player
I tried keeping this simple but still not working. So here is 1 scripts I tried above. Please post correct script for me so I can add it to my image/gameobject and move on.
PLEASE PLEASE Someone who is good at this HELP!I literally spent a ton of time and need pro help!
I don’t think your problem is in the code.
I have found similar problems when creating and using old style animations (not mecanim). It seems to be a bug introduced in the last versions.
Unfortunately when this happened to me I had to recreate the animations.
For the time being what I do and recomend is to follow these exact steps when creating animations.
DO THIS FIRST. Add the animation component to the GameObject to be animated. If you don’t, an Animator component is created and that interferes with the old style animations.
Then open de animation window and create an animation clip from there.
Add your curves and animate
As soon as you finished your first animation, go to your Animatiosn project folder and drag the animation clip to the Aimation property of the Animation component in the inspector, so this one is the default animation. Most of the times I found problems I had forgotten to do this.
If you want to add more animations to the GameObject, do so but don’t forget to do step 4 first.