Question by
EvanEvan · Nov 06, 2016 at 04:14 AM ·
rigidbody2dvelocityvector2cs0029
JohnyControllerScript.cs(20,17): error CS0029: Cannot implicitly convert type `UnityEngine.Vector2' to `UnityEngine.Rigidbody2D'
I have been following a tutorial about how to make an infinite runner. Everything has been fine so far however I have encountered an error that I need help with.
using UnityEngine;
using System.Collections;
public class JohnyControllerScript : MonoBehaviour {
public float maxSpeed = 10f;
bool facingRight = true;
private Rigidbody2D johnyRigidbody2D;
void Start () {
this.johnyRigidbody2D = GetComponent<Rigidbody2D>();
}
void FixedUpdate () {
float move = Input.GetAxis ("Horizontal");
johnyRigidbody2D = new Vector2 (move * maxSpeed, this.johnyRigidbody2D.velocity.y);
}
}
This is my entire script for the controller. I could use some help figuring out how to fix the error.
Comment
Your answer
Follow this Question
Related Questions
How to stop cube from sliding (rg2d.velocity) 1 Answer
Why angle between these two velocities is 45? 2 Answers
Rotating a velocity vector while keeping the magnitude 0 Answers
Unity Rigidbody2D bug 0 Answers
Rigidbody2D and some vectors 1 Answer