Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class CameraOrientation : MonoBehaviour
- {
- [Header("Refrences")]
- public Transform orientation;
- public Transform player;
- public RigidBody rb;
- // Start is called before the first frame update
- void Start()
- {
- }
- // Update is called once per frame
- private void Update()
- {
- Vector 3 viedDir = player.position -
- new Vector3(transform.position.x, player.position.y transform.position.z);
- orientation.forward = viewDir.normalised
- float horizontalInput = Input.GetAxis("Horizontal");
- float verticanInput = Input.GetAxis("Vertical");
- Vector3 inputDir = orientation.forward * veritcalInput + orientation.right + horizontalInput;
- if (inputDir != Vector3.zero)
- {
- player.forward = vector3.Slerp(player.forward, inputDir.normalised, Time.deltatim * rotationSpeed);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment