Hi, I checked before posting the question, I found a lot of questions with answers like “use transform.Translate” but Im not sure I understand how to use it in my case. I have a Joystick asset added to game, the movement was working just as I needed while I was using transform.position, but because its not calculating collisions my character kept passing through some walls(corners to be precise) in the house and I decided to change to rigidbody.velocity - movement.
The problem is it moves around world axis and I honestly dont know what to do atm… tried a couple of different things but those doesnt work or work not the way they supposed to… This might be very primitive question, please take a look at code
void FixedUpdate()
{
var x = joystickFloat.Horizontal * Time.deltaTime * turnSpeed;
transform.Rotate(0, x, 0);
// GetComponent<AudioSource>().UnPause(); //meow
if (!cantWalk)
{
Debug.Log("moving");
var w = joystick.Vertical * Time.deltaTime * moveSpeed;
var y = joystick.Horizontal * Time.deltaTime * moveSpeed;
Vector3 movement = new Vector3(joystick.Horizontal. * Time.deltaTime * moveSpeed, 0, joystick.Vertical * Time.deltaTime * moveSpeed);
rbPlayer.velocity = movement;
}
}
Trying to translate Vector3 movement to local axis… got stuck, explain please