- Home /
Question by
LiamConnelley · Dec 06, 2016 at 06:55 AM ·
script.componentscript erroradding
what is a script component??
i get a message when I try to add the script to my player saying: Cant add script to component 'Player' Because the script class cant be found...
This is my script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class playermovement : MonoBehaviour
{
private Rigidbody2D myRidgidBody;
[SerializeField]
private float Speed;
// Use this for initialization
void Start ()
{
myRidgidBody = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void fixedUpdate ()
{
float horizontal = Input.GetAxis("horizontal");
HandleMovement(horizontal);
}
private void HandleMovement(float horizontal)
{
myRidgidBody.velocity = new Vector2(horizontal * Speed, myRidgidBody.velocity.y);
}
}
email me back at: Lime2004@icloud.com
Comment
Line 11 needs to be FixedUpdate (case matters); is this class named/saved as "playermovement" all lowercase?
Your answer
Follow this Question
Related Questions
I can't use Rigidbody2D in my scripts, I can't find rigidbody2d in my script 3 Answers
2D Animation does not start 1 Answer
How can i set transform.position on y ? And why i'm getting error cannot convert double to float ? 3 Answers
How to share varibles betweent scripts 4 Answers
"The associated script cannot be loaded" on every script in the project 0 Answers