Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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 connorwforman · Oct 24, 2017 at 01:13 AM · scripting problemmovement

Movement script (ironically) is not moving.

I wrote this movement script, and one minute it moved, the next it stopped. What did I do wrong and how would I fix it? using System.Collections; using System.Collections.Generic; using UnityEngine;

 public class Player_Movement_Script : MonoBehaviour {
 
     float moveFB; 
     float moveLR; 
     public float speed = 2f; 
     CharacterController player; 
     float rotX; 
     float rotY; 
     public float sensitivity = 5f; 
     public GameObject eyes; 
 
     void Start () {
         player = GetComponent<CharacterController> (); 
     }
     
     void Update () {
 
         moveFB = Input.GetAxis ("Vertical") * speed; 
         moveLR = Input.GetAxis ("Horizontal") * speed; 
 
         rotX = Input.GetAxis ("MouseX") * sensitivity; 
         rotY = Input.GetAxis ("MouseY") * sensitivity; 
 
         Vector3 movement = new Vector3 (moveLR, 0, moveFB);
         transform.Rotate (0, rotX, 0); 
         eyes.transform.Rotate (rotY, 0, 0); 
         movement = transform.rotation * movement;
         player.Move (movement * Time.deltaTime); 
     }
 }
 
Comment
Add comment · Show 1
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 connorwforman · Oct 24, 2017 at 10:31 AM 0
Share

So this is weird. Nothing wrong with the script. I wonder what is happening.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by AlienNova · Oct 24, 2017 at 02:02 AM

 movement = transform.rotation * movement;

Unity stores rotation as a Quaternion, not a Vector3. I would love to help you further, but I need to see your Move () function to help further

Comment
Add comment · Show 1 · 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 Bunny83 · Oct 24, 2017 at 02:40 AM 0
Share

Uhm that line is correct. It rotates the movement vector from local space to worldspace. The "$$anonymous$$ove" method is part of the CharacterController.

avatar image
0

Answer by Bunny83 · Oct 24, 2017 at 02:39 AM

I don't see anything wrong in your code. Make sure:

  • You actually attached the script to your player.

  • Your player object has a CharacterController component attached next to your script.

  • You did not set speed in the inspector to "0".

  • Your object is not deactivated or the script is disabled.

  • You don't set Time.timeScale to 0 somewhere.

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.

Follow this Question

Answers Answers and Comments

152 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 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

How do I keep my character facing the direction of travel after movement stops? 1 Answer

What should i write that when i press "Shift" it will speed up idk how shift is named? Here's the code: 1 Answer

Need help with my movement script.. :( 1 Answer

Question about moving an object technique 3 Answers

How to move the main camera in Google Cardboard? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges