I’m trying to figure out how to add a simple jump function to this script, and am totally lost. I’m trying to learn, but this is so foreign to me that I can’t figure it out. Perhaps if I had done the code myself, I may have had a better idea about all of it, but here it is. I did not write this code. I was simply given it and it works perfectly except my little ball cannot jump. Also, when I press “A” the ball moves right and “D” moves it left. Script below:
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(Rigidbody))]
public class SphereMovement : MonoBehaviour
{
[SerializeField] float speed = 1;
Rigidbody rigidbodyInstance;
float movementInput = 0;
void Start()
{
rigidbodyInstance = GetComponent<Rigidbody>();
}
void Update()
{
GetMovementInput();
}
void FixedUpdate()
{
Move();
}
void GetMovementInput()
{
movementInput = Input.GetAxis("Horizontal");
}
void Move()
{
Vector3 direction = new Vector3(movementInput, 0.0f, 0.0f);
rigidbodyInstance.AddForce(direction * speed);
}
}
As I’ve stated, I did not write this. Any help would be much appreciated, so thank you in advance