Added things
This commit is contained in:
29
Assets/Scripts/Weapons/AutoAim.cs
Normal file
29
Assets/Scripts/Weapons/AutoAim.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AutoAim : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
public GameObject enemy;
|
||||
|
||||
public float lookSpeed = 200f;
|
||||
|
||||
public GameObject player;
|
||||
public Camera camera;
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
Vector3 direction = enemy.transform.position - camera.transform.position;
|
||||
Quaternion targetRotation = Quaternion.LookRotation(direction);
|
||||
Quaternion lookAt = Quaternion.RotateTowards(camera.transform.rotation, targetRotation, Time.deltaTime * lookSpeed);
|
||||
camera.transform.rotation = lookAt;
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user