I am still learning unity and C# and am not entirely sure how everything operates. I am trying to make a first person camera that uses a rigidbody in order for it to interact with physics. I have got the player to move along the right axis perfectly. as the camera rotates so does the character and moves relative to the right axis’s direction. I did the same thing for the forward direction and it does not appear to be working. my settings for the input manager are right, there is no errors, and it is doing the same as the right axis which is working fine. I don’t know where I am going wrong. any help is great, thanks!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RigidbodyPlayerMove : MonoBehaviour
{
public float speed = 10;
public Rigidbody rb;
public Transform orientation;
float Hinput;
float Vinput;
void Start()
{
speed = speed * 100;
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
private void Update()
{
movement();
}
void movement()
{
Hinput = Input.GetAxis("Horizontal");
Vinput = Input.GetAxis("Vertical");
// ignore this addforce attempt at movement.
//rb.AddForce(orientation.transform.forward * Hinput * speed * Time.deltaTime);
//rb.AddForce(orientation.transform.right * Vinput * speed * Time.deltaTime);
rb.velocity = transform.forward * Vinput * speed * Time.deltaTime;
rb.velocity = transform.right * Hinput * speed * Time.deltaTime;
}
}