Question by
AkashJaiswal · Aug 05, 2016 at 01:55 PM ·
playerscript errormovingroll a ball
Error Roll a Ball game - 2 of 8-Moving the Player
Roll a Ball 2 of 8 Moving the Player Script error this is my code " using UnityEngine; using System.Collections;
public class PlayerController : MonoBehaviour {
public float speed = 0.0f;
private Rigidbody rb;
void Start ()
{
rb = GetComponent<Rigidbody> ();
}
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rb.AddForce (movement = speed);
}
} " error "Cannot implicitly convert type 'float' to 'UnityEngine.Vector3'
I am just a biggner so please provide me solution as soon as possible.
ice-screenshot-20160805-190342.png
(217.9 kB)
ice-screenshot-20160805-190325.png
(98.7 kB)
Comment
Answer by Landern · Aug 05, 2016 at 02:13 PM
Line 16, you're setting a movement variable of type Vector3 to a float(local field to the class), did you mean to multiply the movement by the speed?
rb.AddForce (movement * speed);