-
Автор темы
- #1
Надо так чтобы при повороте камерой персонаж двигался по направлению камеры
using UnityEngine;
using Cinemachine;
using UnityEngine.UI;
[RequireComponent(typeof(Rigidbody), typeof(BoxCollider))]
public class PlayerCont : MonoBehaviour
{
[SerializeField] private Rigidbody _rb;
[SerializeField] private FixedJoystick Joystick;
[SerializeField] private Animator[] animations;
[SerializeField] public CinemachineVirtualCamera CVC;
[SerializeField] private float jumpForce = 150f;
[SerializeField] private float MoveSpeed;
public void jump()
{
_rb.AddForce(new Vector3(_rb.velocity.x, jumpForce));
}
private void FixedUpdate()
{
_rb.velocity = new Vector3(Joystick.Vertical * MoveSpeed, _rb.velocity.y, Joystick.Horizontal * -MoveSpeed);
}
}
using UnityEngine;
using Cinemachine;
using UnityEngine.UI;
[RequireComponent(typeof(Rigidbody), typeof(BoxCollider))]
public class PlayerCont : MonoBehaviour
{
[SerializeField] private Rigidbody _rb;
[SerializeField] private FixedJoystick Joystick;
[SerializeField] private Animator[] animations;
[SerializeField] public CinemachineVirtualCamera CVC;
[SerializeField] private float jumpForce = 150f;
[SerializeField] private float MoveSpeed;
public void jump()
{
_rb.AddForce(new Vector3(_rb.velocity.x, jumpForce));
}
private void FixedUpdate()
{
_rb.velocity = new Vector3(Joystick.Vertical * MoveSpeed, _rb.velocity.y, Joystick.Horizontal * -MoveSpeed);
}
}