- Home /
 
               Question by 
               GrimmTheReaper76 · Sep 03, 2017 at 11:26 PM · 
                c#scripting problemerror  
              
 
              Error CS1525 Unexpected symbol `float'
I tried to run a script, it was a little makeshift, however I think that it should work, I don't see the issue here, maybe one of you guys could help? It said that the errors were located in line 5 and 7, anyways here's the script.
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public float speed;
 
 private float Rigidbody2D rb2d;
 
 
 public class PlayerController : MonoBehaviour
 
 {
     void Start () 
     {
         rb2d = GetComponent<Rigidbody2D> ();
     }
 
 
     void FixedUpdate () 
     {
         float moveHorizontal = Input.GetAxis ("Horizontal");
         rb2d.AddForce (movement * speed);
         if (Input.GetButtonDown ("Jump")) 
         {
             rb.velocity = new Vector2 (0, 10, 0);
         }
     }
 }
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by jasonlu00 · Sep 03, 2017 at 11:45 PM
Fixed:
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 
 public class NewBehaviourScript: MonoBehaviour
 {
     public float speed;
 
     private Rigidbody2D rb2d;
 
     void Start()
     {
         rb2d = GetComponent<Rigidbody2D>();
     }
 
 
     void FixedUpdate()
     {
         float moveHorizontal = Input.GetAxis("Horizontal");
         rb2d.AddForce(moveHorizontal * speed);
         if(Input.GetButtonDown("Jump"))
         {
             rb2d.velocity = new Vector2(0, 10, 0);
         }
     }
 }
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                