I need a script to rotate the player based on their input, like as a quaternion not rotate/as if they were pivoting around a point.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class rotate : MonoBehaviour
{
public float rotationSpeed = 5f;
public Transform pivotPoint; // Reference to the empty GameObject
void Update()
{
float horizontalInput = Input.GetAxis("Horizontal");
float verticalInput = Input.GetAxis("Vertical");
float horizontalRotation = horizontalInput * rotationSpeed * Time.deltaTime;
float verticalRotation = verticalInput * rotationSpeed * Time.deltaTime;
// Apply rotation to the pivot point (empty GameObject)
pivotPoint.Rotate(Vector3.up, horizontalRotation);
pivotPoint.Rotate(Vector3.right, verticalRotation);
}
}
What is "pivotPoint"? The pivotPoint should be the center of the player. Or just put this script on the player and call transform.Rotate instead of pivotPoint.Rotate
– ArachnidAnimalnever mind! I have a better script made.
– TheRealWoolis