• 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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Root Movement with Additive Layers 0 Answers

After working in animator controller, sprite won't appear in game mode 0 Answers

Animation Different in Unity 5 1 Answer

Animation Loop 1 Answer

How do I setup a Shooting Trigger to make an Animation play on a Platform? 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges