- Home /
How to create a collider-trigger that will start an animation when you press E
Hey guys! I have been roaming this forum, and found several options, but nothing like what i want to do...
And I'm terrible in code, and espacially in combining them, so i was really hoping you'd like to help me:)
what I want to do is the following:
I have a first person controller, what i want to do is that when he presses a button, a animation starts..
the easiest way to do this seemed like this for me:
function OnCollisionStay (col : Collision) {
if (col.gameObject.tag == "Player" && Input.GetKeyDown(KeyCode.E) ) {
Animation.Play();
}
}
this does not work, I hooked up a animation component with an animation for the object, but the console still reports: Assets/ANIMETRIGGER.js(7,11): BCE0020: An instance of type 'UnityEngine.Animation' is required to access non static member 'Play'.
I don't know what to do:/
Making a prefab out of a script like this would help me so much in my game development, since buttons are a big part of the game play
Your answer
Follow this Question
Related Questions
Trigger Animation doesn't work, please help me. 1 Answer
Collision for Animating Meshes 1 Answer
Collider on Bone changes Bone Origin/Pivot 1 Answer
How to stop an animation on collision 0 Answers
Player to Door Collision and Animation 3 Answers