
It looks like you're new here. If you want to get involved, click one of these buttons!
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public Rigidbody rb;
public float ForwardForce = 2000f;
public float sidewaysForce = 500f;
// Update is called once per frame
void FixedUpdate()
{
rb.AddForce(0, 0, ForwardForce * Time.deltaTime);
if (Input.GetKey("d"))
{
rb.AddForce(sidewaysForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
}
if(Input.GetKey("a"))
{
rb.AddForce(-sidewaysForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
}
if (Input.GetKey("left"))
{
rb.AddForce(-sidewaysForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
}
if (Input.GetKey("right"))
{
rb.AddForce(sidewaysForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
}
if (rb.position.y < -1f)
{
FindObjectOfType<GameManager>().EndGame();
}
}
Answers
I was looking forward to a lot of what lolbeans the article is saying and I really hope what the article says will help many people in life. Let's work together to be able to overcome difficult times towards happy things.