performing animation on another player
Hello, I have two game objects, I want one player to do some actions on second one, if they are close enough to each other. In detail I want first player to attach on second. There are several instance of both objects but I wont to do animation on closest one. how can I do it? Thank you!
basically I want second player to get on top of first.
This script prints "find". ins$$anonymous$$d of that it must do animation. thank you for any comments. if my explanation is little bit not informative ask me any question. I am very new to unity.
using UnityEngine;
using System.Collections;
public class Do_animation: $$anonymous$$onoBehaviour
{
public GameObject go;
public float dista = 2;
void Start()
{
go = GameObject.FindWithTag("box");
}
void Update()
{
float dist = Vector3.Distance(go.transform.position, transform.position);
if (dist < dista)
Debug.Log("find");
}
}
Your answer
Follow this Question
Related Questions
Making a hit meter 1 Answer
Help with a door slam trap 0 Answers
Hey people i want to know is there a way to play animation for the first time player plays 1 Answer
How do I make it so a death animation will play when I hit an enemy? 0 Answers
Trigger the Animation #2 after Animation #1 was triggered 0 Answers