Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Stef · Jul 17, 2014 at 04:19 PM · c#animationcollidertrigger

Trigger transition to another animation.

Hey Guys,

I'm trying to set up my animations so that when my zombie enters the trigger collider of the tower he transitions to an attack animation.

Basically, I'm trying to trigger a transition to another animation when entering a trigger. I'm very new to scripting and getting a few errors on my script. Any feedback is greatly appreciated:

 using UnityEngine;
 using System.Collections;
 
 public class Strike_Tower : MonoBehaviour 
 {
     void OnTriggerEnter(Collider other) 
     {
         if(collision.transform.tag == "Tower")
            {
            }
            BaseLayer.Trigger = true;
     }
 }

Thanks,

Stef

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Huacanacha · Jul 17, 2014 at 04:38 PM 0
Share

You need to provide a more complete explanation so we can help... what errors are you getting, what is BaseLayer and where does it come from, how exactly are you trying to call the animation transition etc.

2 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by findujanvier · Jul 17, 2014 at 04:46 PM

Hope this help!

 using UnityEngine;
 using System.Collections;
  
 public class Strike_Tower : MonoBehaviour 
 {
     Animator anim;
    
     void Start(){
         anim = GetComponent<Animator>();
     }
  
     void OnTriggerEnter(Collider other) 
     {
         if(collision.transform.tag == "Tower")
            {
                 anim.setTrigger("YOUR_TRIGGER_NAME_HERE");
            }
            
     }
 }
 }
Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Stef · Jul 17, 2014 at 05:01 PM 0
Share

Thanks findu... I get a couple of errors when I run your awesome script:

Assets/Strike_Tower.cs(14,20): error CS0103: The name collision' does not exist in the current context > Assets/Strike_Tower.cs(16,30): error CS1061: Type UnityEngine.Animator' does not contain a definition for setTrigger' and no extension method setTrigger' of type `UnityEngine.Animator' could be found (are you missing a using directive or an assembly reference?)

??? Thoughts?

I should also add that I'm using mecanim, and trying to use the trigger parameter to move from one animation state to another...

and thanks for the help!!!!

Stef

avatar image findujanvier · Jul 18, 2014 at 01:36 AM 0
Share

You have not set tag for your tower

avatar image findujanvier · Jul 18, 2014 at 01:37 AM 0
Share

Click on tower gameobject > click to tag drop down > add tag > create new tag, named "tower" > then set tag to your tower

avatar image
0

Answer by Stef · Jul 18, 2014 at 07:23 PM

Solved - Didn't have rigid body on game character... thanks all

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

23 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

C#: Climb ledge while inside collider 1 Answer

How to trigger animation on a different object? 1 Answer

How do I make the enemy ai animations play after the player exit the on trigger collider on the enemy ai 0 Answers

OnTriggerEnter Not Working 1 Answer

Triggering animation on click when a key is collected 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges