Unity
10
Вклад в тег
private void OnCollisionEnter(Collision other)
{
var normal = other.GetContact(0).normal;
var collisionTransform = other.transform;
if (normal == collisionTransform.up)
{
Debug.Log("Top");
}
if (normal == -collisionTransform.up)
{
Debug.Log("Down");
}
if (normal == collisionTransform.right)
{
Debug.Log("Right");
}
if (normal == -collisionTransform.right)
{
Debug.Log("Left");
}
if (normal == collisionTransform.forward)
{
Debug.Log("forward");
}
if (normal == -collisionTransform.forward)
{
Debug.Log("back");
}
}
Transform player;
Queue<Transform> positions;
private void Start()
{
player = GetComponent<Transform>();
positions = new Queue<Transform>();
}
private void Update()
{
Move()
}
private void Move()
{
// move
positions.Enqueue(player.transform);
}