Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

Hi, I need help fixing this simple code

$
0
0
I am totaly new to unity and C#, and trying to make a sprite move up and down on the screen. I followed a tutorial and this is my code: using System.Collections; using System.Collections.Generic; using UnityEngine; public class Movement : MonoBehaviour { public float moveSpeed = 5f; public Rigidbody2D rb; private vector movement; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { movement = Input.GetAxisRaw("Vertical"); } void FixedUpdate() { rb.MovePosition(rb.position + movement + moveSpeed + Time.fixedDeltaTime); } } I am getting this error: **Assets\Movement.cs(28,25): error CS0019: Operator '+' cannot be applied to operands of type 'Vector2' and 'float'** How can I fix it?

Viewing all articles
Browse latest Browse all 2891

Trending Articles