first commit
This commit is contained in:
commit
aa44d3ad70
1585 changed files with 277994 additions and 0 deletions
60
Assets/Resources/Scripts/StepsLink/ArrowSript.cs
Normal file
60
Assets/Resources/Scripts/StepsLink/ArrowSript.cs
Normal file
|
@ -0,0 +1,60 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ArrowSript : MonoBehaviour
|
||||
{
|
||||
private GameObject targetObj;
|
||||
|
||||
// set the target obj
|
||||
public void SetTargetObj(GameObject obj)
|
||||
{
|
||||
targetObj = obj;
|
||||
}
|
||||
|
||||
// method to place the arrow over the passed object
|
||||
private void PlaceArrowOverObject(GameObject obj)
|
||||
{
|
||||
// get the obj position
|
||||
Vector3 objPos = obj.transform.position;
|
||||
|
||||
// put the arrow over the obj
|
||||
transform.position = objPos;
|
||||
|
||||
// rotate the arrow to face the obj
|
||||
transform.LookAt(obj.transform);
|
||||
|
||||
// increase the arrow height from the obj top
|
||||
transform.position += new Vector3(0, 0.3f, 0);
|
||||
|
||||
// show
|
||||
ShowArrow(obj);
|
||||
}
|
||||
|
||||
// method to show the arrow
|
||||
public void ShowArrow(GameObject obj)
|
||||
{
|
||||
// enable the arrow
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
// rotate on y axis
|
||||
transform.Rotate(0.5f, 0, 0);
|
||||
|
||||
// if the target obj is not null
|
||||
if (targetObj != null)
|
||||
{
|
||||
// place the arrow over the target obj
|
||||
PlaceArrowOverObject(targetObj);
|
||||
}
|
||||
}
|
||||
|
||||
// method to hide the arrow
|
||||
public void HideArrow()
|
||||
{
|
||||
// disable the arrow
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue