how would you offer me to move a cube which has a rigidbody component with WASD ?
i have already created a script and attached it to the cube gameobject.
using UnityEngine;
public class Player : MonoBehaviour
{
[SerializeField]
private float m_moveSpeed = 1;
[SerializeField]
private float m_jumpForce = 1;
[SerializeField]
private Rigidbody m_rigidBody;
void Awake()
{
}
private void Start()
{
}
void FixedUpdate()
{
}
}
Can you be more specific about the qualities of movement you’re looking for? Are you looking for the object to accelerate smoothly or instantly move at a desired speed? Do you want the object to keep going when you release the keys or to keep moving in whatever direction they were moving?
1 Like
thanks for your answer, here are more explanations:
i need the player moves instantly at a desired speed and when i release the keys, then player stop moving.
Also, player direction does not matter, because it is a cube gameobject.
also when i press space key, i need the player jumps.
i have attached a rigidbody and animator component to the cube by the way.
thanks so much.