- Home /
I can't run simple movement script from "Space Shooter".
I am a complete beginner with game development and script. I'm trying to work through the "Space Shooter" beginner project from the unity site, and I can't get the script from the video tutorials to work.
This is the script:
using UnityEngine;
using System.Collections;
public class Player_Controller : MonoBehaviour
{
void fixedUpdate ()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rigidbody.velocity = movement;
}
}
The correct keyboard keys are set in the input manager and it comes up with no error in the console or footer, but where it is added as a component to the player object, it says "The associated script cannot be loaded. Please fix any compile errors and assign a valid script.
Same problem. "F" is capital.
using UnityEngine;
using System.Collections;
public class PlayerController : $$anonymous$$onoBehaviour
{
public float speed;
void FixedUpdated ()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rigidbody.velocity = movement * speed;
}
}
Any ideas?
UPD: Ok, I've tried a "done" script, the inclination (rotation of the ship) works but it still doesnt move.
UPD2: Ok, somehow i got rid of error massage. Now it just doesn't move.
Answer by Graham-Dunnett · Feb 04, 2014 at 09:21 PM
you need a capital f
for your function - FixedUpdate()
.
Your answer
![](https://koobas.hobune.stream/wayback/20220613132546im_/https://answers.unity.com/themes/thub/images/avi.jpg)