Скрипт передвижения объектов при обновлении переходе дороги
This commit is contained in:
24
Assets/MoveWithTileScript.cs
Normal file
24
Assets/MoveWithTileScript.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MoveWithTileScript : MonoBehaviour
|
||||
{
|
||||
private TileManagerScript _TileManagerScript;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_TileManagerScript = GameObject.FindGameObjectWithTag("Tile Manager").GetComponent<TileManagerScript>();
|
||||
|
||||
if (_TileManagerScript != null)
|
||||
{
|
||||
_TileManagerScript.MoveWithTile = this;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdatePos()
|
||||
{
|
||||
Vector3 newVector = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z + _TileManagerScript.DistanceTiles);
|
||||
gameObject.transform.position = newVector;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user