🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

My Character Movement script is not working 2D Top down view brackeys tutorial Unity

Started by
4 comments, last by Onions.ILikeOnions 4 years, 9 months ago

My top down character movement script aint working, only the screen moves.

Mere is the tutorial https://www.youtube.com/watch?v=whzomFgjT50&t=41s

 

And here is my Script

 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class waw : MonoBehaviour
{
   
   public float moveSpeed = 5f;
 
   public Rigidbody2D rb;
 
Vector2 movement;
    // Update is called once per frame
    void Update()
    {
      movement.x = Input.GetAxisRaw("Horizontal");
      movement.y = Input.GetAxisRaw("Vertical");
    }
 
void FixedUpdate (){
//movment
rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime);
}
 
}
Advertisement

is your rigidbody assigned in the inspector?

 

are there any errors in the console? 

No actually i don't think it has RigidBody Ill update you in a bit

and yes there are errors in the console

some of them are about the wiggley brackets.

this happend

Capture.JPG

59 minutes ago, Hydro-Games said:

is your rigidbody assigned in the inspector?

 

are there any errors in the console? 

 

You need to assign the Rigidbody in the inspector go to your script in the inspector and drag and drop the Rigidbody in the right slot

ok thanks dude

 

This topic is closed to new replies.

Advertisement