Answer the question
In order to leave comments, you need to log in
I'm making a 2D platformer on unity using this video https://youtu.be/5vhMXhic2S8 I can't do anything. I write the code in fact exactly exactly. How can I fix this?
I'm making a 2D platformer on unity using this video
https://youtu.be/5vhMXhic2S8
I can't do anything. I write the code in fact exactly exactly, but it does not work. during programming, many components are not highlighted in color.
Here is the script code:
using UnityEngine;
public class controller : MonoBehaviour
{
public float speed;
public float jumpForce;
private float moveInput;
private Rigidbody2D rb;
private void start()
{
rb = GetComponent();
}
private void FixedUpdate()
{
moveInput = Input.GetAxis("Horizontal");
rb.velocity = new Vector2(moveInput * speed, rb.velocity.y);
}
}
Answer the question
In order to leave comments, you need to log in
rb = GetComponent();
I forgot to specify Rigidbody2D ) in <> also don't forget to add the RigidBody2D component to your player
Also don't confuse the Rigidbody2d component with the Rigidbody
Maybe I forgot to set the speed in the inspector panel
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question