Answer the question
In order to leave comments, you need to log in
What is the correct way to code jump for a character in Unity?
Unity started throwing an error after adding the code for the player to jump. I can't find any errors.
-------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehavior
{
public float speed;
private RigidBody2D rb;
void Start()
{
rb = GetComponent();
}
void FixedUpdate()
{
transform.Translate(direction.normalized * speed);
}
void Update()
{
if (Input.GetButtonDown(KeyCode.Space))
rb.AddForce(Vector2.up * 1000);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question