Hello
I need help, i would like to have an object (cube or something i made in another 3D program) to be a button so it activates a animation, so when something hits the button which could be an object like a cube or something i made earlier it activates the animation you see what i mean what i would like to happen in this video Robot Wars House Robot Rebellion with Squirmin Vermin - YouTube go to 2:00-2:05
Please help
Thank you
3 Answers
3
There’s a few ways you could do this with colliders or triggers. I’ll outline one way:
- Attach a collider to your “Button”
- Enable the collider to be a trigger
- Drop this script onto your Button. I’ll do an example in JS:
var objectOfAnimation : GameObject; // Drag your object with the animation into this slot in the inspector
function OnTriggerEnter(other : Collider) {
if (other.tag == "whatever object you define that enters the trigger to play the animation") {
objectOfAnimation.animation.Play("theAnimation"); }
}
var objectOfAnimation : GameObject; // Drag your object with the animation into this slot in the inspector
function OnTriggerEnter(other : Collider) {
if (other.tag == “untitled”) {
objectOfAnimation.animation.Play(“pit 2”); }
}
var objectOfAnimation : GameObject; // Drag your object with the animation into this slot in the inspector
function OnTriggerEnter(other : Collider) {
if (other.tag == “untitled”) {
objectOfAnimation.animation.Play(“pit 2”); }
}
Should be other.collider.gameObject.tag :P
– Kleptomaniac@stingman it dosent work :( still wont desend
– dalekandjedipost your code and I'll help you fix it
– Selosoft