hello I have this script and I would like to know how to implement the rotation of the player so that it is always the one of the camera
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
public FixedJoystick moveJoystick;
public float fuerzaDeSalto = 8f;
public bool puedoSaltar;
public Animator anim;
public AudioSource jumpxd;
public ParticleSystem polvo;
private Rigidbody rb;
private float moveH,moveV,speedMove=22;
void Start()
{
rb = GetComponent();
polvo.Stop();
}
void movePlayer()
{
moveH = moveJoystick.Horizontal;
moveV = moveJoystick.Vertical;
Vector3 dir = new Vector3(moveH,0, moveV);
rb.velocity = new Vector3(moveHspeedMove, rb.velocity.y, moveVspeedMove);
if(dir != Vector3.zero)
{
transform.LookAt(transform.position + dir);
polvo.Play();
}
if(dir != Vector3.zero)
{
}
if(dir != Vector3.zero)
{
anim.SetBool(“Caminar”, true);
}
else
anim.SetBool(“Caminar”, false);
}
void Update()
{
movePlayer();
if (puedoSaltar)
{
if (Input.GetKeyDown(“space”))
{
anim.Play(“Saltar”);
rb.AddForce(new Vector3(0,fuerzaDeSalto,0), ForceMode.Impulse);
jumpxd.Play();
}
}
else
{
EstoyCayendo();
}
}
public void EstoyCayendo()
{
anim.SetBool(“Saltar”, false);
}
public void xd()
{
if (puedoSaltar){
anim.Play(“Saltar”);
rb.AddForce(new Vector3(0,fuerzaDeSalto,0), ForceMode.Impulse);
jumpxd.Play();
polvo.Play();
}
else{
}
}
}