22 lines
510 B
C#
22 lines
510 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Turret : MonoBehaviour
|
|
{
|
|
public float speed = 10;
|
|
public bool isHorizontal = false;
|
|
|
|
void Update()
|
|
{
|
|
transform.position += getMovementVector() * speed * Time.deltaTime;
|
|
}
|
|
|
|
Vector3 getMovementVector()
|
|
{
|
|
float x = isHorizontal ? Input.GetAxis("Horizontal") : 0;
|
|
float y = isHorizontal ? 0 : Input.GetAxis("Vertical");
|
|
|
|
return new Vector3(x, y, 0);
|
|
}
|
|
}
|