Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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
0
Question by mk025 · Aug 03, 2016 at 01:59 PM · animationunity 53danimator controllertriggers

How do I activate an animation when a gameobject enter the Collider of the other animated object

Hi, I'm new on unity , and I want to make an animation on several gameobjects, with a delay between them. I have 2 animated objects, the first starts when the game is played and the second needs to be triggered only when a gameobject (that is following a way via an other script) enters it's collider( that I've set to be the Trigger). To do so I've made an animation controller tht switches between two states ( 'Idle'and 'playing') in btw those two states the value of a Bool ( named 'trans' changes from true to false) , this value is going to be used in the script as follows : /////////////////////////////////////////////////////////////////////////////

using UnityEngine;

using System.Collections;

public class testcylindre : MonoBehaviour {

 public bool trans;

 private Animator ani;

 private GameObject Player;

 void Start () {
     
 }
 
 // Update is called once per frame
 void Update () {
     ani = GetComponent<Animator> ();
 }

 void onTriggerEnter(Collider other){
     ani.SetBool ("trans", true);
 }

 void onTriggerExit(Collider other){
         ani.SetBool ("trans", false);
 }

}

But when I play the scene even when the objects enters the collider the animation doesn't begin, and when i've opened the Animator window while thegame is playing i've noticed tht the Idle state is always looping and it doesn'tgo to the Playing state where the motion is set to the animation.

Any help wiould be welcomed, thanks in advance.

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 XenonSpher · Aug 04, 2016 at 12:47 PM 0
Share

check the ontriggerenter first by putting a Debug.Log. add a script in the ontriggerenter:

 Debug.Log("if this message got outputed in console then it means ontriggerenter really did work if not then no");

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by mk025 · Aug 04, 2016 at 05:02 AM

I've found the SOLUTIOOON . ok maybe because i'm a noob I didn't knew this, but basically you have to add the property Rigid Body and set kinematic to true and The object coming towards the animated to be other object will be recongnized by it's collider and therefore the animaton will be triggered.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Unity 5 Controlling Animation with UI Button 0 Answers

Hello! I have some issues with animations. 1 Answer

What is the best way nowadays to record a film/movie(mp4) with Unity? 1 Answer

Cant get Animator Controller to work properly 2 Answers

What would be the best way to do something based on the animation state of the character? 0 Answers


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