Hello,
I have a project in which I have an orbit style camera.
I was wondering how I can make this relative to my player movement.
Ideally this would be done by copying the camera’s y rotation and applying it to the moving object too.
How can I do this? (if it’s possible).
Here is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RigidMovement : MonoBehaviour
{
public float speed;
private Rigidbody rb;
public Transform relativeTransform;
public Vector3 camDir;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
float h = Input.GetAxisRaw("Horizontal");
float v = Input.GetAxisRaw("Vertical");
Vector3 tempVect = new Vector3(h, 0, v);
tempVect = tempVect.normalized * speed * Time.deltaTime;
rb.MovePosition(transform.position + tempVect);
}
}
Thanks in advance,
dusty