Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
860 B
5
Indexable
Never
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RotComp : MonoBehaviour
{
    public Transform Turret;
    public float TowerSpeed;
    public float TowerAngle;
    public float TowerAngle2;

    void Start()
    {
        TowerAngle = 0;
        TowerAngle2 = 0;
       




    }
    // Update is called once per frame
    void Update()
    {

        rotatetower();


    }

    void rotatetower()
    {
        TowerAngle += Input.GetAxis("Mouse X") * TowerSpeed * Time.deltaTime;
        TowerAngle2 += Input.GetAxis("Mouse Y") * TowerSpeed * Time.deltaTime;


        TowerAngle = Mathf.Clamp(TowerAngle, -90, 90);
        TowerAngle2 = Mathf.Clamp(TowerAngle, 0, 15);


        Turret.transform.rotation = Quaternion.Euler(TowerAngle2, TowerAngle, 0f);



    }
}