using UnityEditor.Experimental.GraphView;
using UnityEngine;
using UnityEngine.Rendering.Universal;
public class PlayerMovement : MonoBehaviour
{
public Rigidbody2D tankRB;
public GameObject player;
public float accelerationFactor = 30f;
public float turnFactor = 3f;
float accelerationInput = 0;
float steeringInput = 0;
float rotationAngle = 0;
public void Awake()
{
tankRB = GetComponent<Rigidbody2D>();
}
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
}
void FixedUpdate()
{
ApplyEngineForce();
ApplySteering();
}
void ApplyEngineForce()
{
Vector2 engineForceVector = transform.up * accelerationInput * accelerationFactor;
tankRB.AddForce(engineForceVector, ForceMode2D.Force);
}
public void ApplySteering()
{
rotationAngle -= steeringInput * turnFactor;
tankRB.MoveRotation(rotationAngle);
}
public void SetInputVector(Vector2 inputVector)
{
steeringInput = inputVector.y;
}
}
I’ve done a tutorial to help make some code to get my player character to move the right way but in two different cases it hasn’t worked due to my * symbol not multiplying. “rotationAngle -= steeringInput * turnFactor;” is the code thats not working as it should.
another problem I’ve had is when trying to multiply a float by Time.deltaTime.
idk if anyone can help but id appreciate any sort of help i can get and I’m sure its probably a easy solution but I haven’t found it yet