• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by PotatOS432 · Oct 13, 2017 at 01:14 AM · movement scripttutorialspace shooter

Space Shooter Tutorial; Player won't move as shown at 7:05 in the Tutorial Video

It pains me to come here but I am unable to figure out how to move the Ship in the Space Shooter. I have followed the video and changed the script as per the Upgraded Guide on ownCloud and looked on the forums for fixes but cannot figure it out. When I hit 'play' it enters play mode so there's no compiler errors but if I press W,A,S,D or Up, Down, Left, Right the Ship won't budge.

The Script is attached to the Player and 'Is Kinematic' is unchecked. If you need further information to aid in your answer I would be happy to provide it.

My Code is this:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class PlayerController : MonoBehaviour
 {
     private Rigidbody rb;
     private void Start()
     {
         rb = GetComponent<Rigidbody>();
     }
     void FixedUpdate()
     {
         float moveHorizontal = Input.GetAxis("moveHorizontal");
         float moveVertical = Input.GetAxis("moveVertical");
 
         Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
         rb.velocity = movement;
     }
 }

I'm sorry to repeat a question that's been asked a lot but I'm having a lot of trouble figuring this out, I'm new to coding and it's confusing jumping from the outdated video tutorial, the Upgrade Guide and forums. I just get lost. And I want to figure this out before moving onto 'Speed' section the video.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by unit_nick · Oct 13, 2017 at 03:56 AM

Lines 14 & 15. There are no axis named "moveHorizontal" & "moveVertical". Try "Horizontal" & "Vertical" in the GetAxis()

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by TBART82 · Oct 13, 2017 at 03:59 AM

@PotatOS432 So I entered your code into Unity and I found the issue. There is no Axis named "moveHorizontal" and "moveVertical". If you go to 'Edit -> Project Settings -> Inputs' you will see there are two axis called "Horizontal" and "Vertical" these are the ones you want to use. So:

Change

 float moveHorizontal = Input.GetAxis("moveHorizontal");
 float moveVertical = Input.GetAxis("moveVertical");

To

 float moveHorizontal = Input.GetAxis("Horizontal");
 float moveVertical = Input.GetAxis("Vertical");

Hopefully this helps!

TBART82

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by PotatOS432 · Oct 15, 2017 at 12:30 AM

@unit_nick , @TBART82 I feel so stupid rn haha. this worked, thank you for your help! Now i can continue :)

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

76 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

can the space shooter tutorial be done without using webGL build? 0 Answers

Creating a spread shot using prefabs 0 Answers

enemy spawn without coroutine? 1 Answer

Why is the boundary not working? 1 Answer

My space ship is sliding to one side and getting stuck there, what would cause this? 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges