Jump to content
  • Advertisement
Onions.ILikeOnions

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

Recommended Posts

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);
}
 
}
Edited by Onions.ILikeOnions
MIstake

Share this post


Link to post
Share on other sites
Advertisement

is your rigidbody assigned in the inspector?

 

are there any errors in the console? 

Edited by Hydro-Games

Share this post


Link to post
Share on other sites

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? 

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!