Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Xysch · Feb 15, 2015 at 08:18 PM · c#movementplayermenuboolean

Player movement isn't working

Hi, so this code here works, but as long as the "menuy" Boolean is not there. What is basically happening is that you cannot move the player until the menu animation is done playing. So I just put a simple boolean to stop the code from running till it was done.

I'm not to sure what's going on because neither the face toward the mouse or the move toward the mouse is working, yet console says it is running. Here's the code for the player:

     public float speed = 4f;
     public bool Menuy = true;
 
     private Vector3 mousePos;
     private Vector3 objectPos;
     private float speedTurn;
     private float angle;
     
 
     // Update is called once per frame
     void Update () {
                 if (Menuy == false) {
                         Debug.Log("WHFwf");
             //Face Mouse
                         Vector3 mousePos = Input.mousePosition;
                         mousePos.z = 0f;
         
                         Vector3 objectPos = Camera.main.WorldToScreenPoint (transform.position);
                         mousePos.x = mousePos.x - objectPos.x;
                         mousePos.y = mousePos.y - objectPos.y;
         
                         var speedTurn = 500f;
         
                         float angle = Mathf.Atan2 (mousePos.y, mousePos.x) * Mathf.Rad2Deg;
                         Quaternion qTo = Quaternion.Euler (new Vector3 (0, 0, angle));
                         transform.rotation = Quaternion.RotateTowards (transform.rotation, qTo, speedTurn * Time.deltaTime);
         
         //Move Player
                         var pos = Input.mousePosition;
                         pos = Camera.main.ScreenToWorldPoint (pos);
                         var dir = pos - transform.position;
                         rigidbody2D.AddForce (dir * speed);
                 }
         }


In another code whenever the animation is done, it just tells this code that it is done changing "menuy" to false:

 playerrrr.GetComponent<Playerrrrr>().Menuy = false;


Idealy, this should start the player to work, and then the game continues. If you have any idea why this isn't working, I'd appreciate it. Thank you

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 Xysch · Feb 15, 2015 at 11:01 PM 0
Share

Still haven't figured it out

1 Reply

· Add your reply
  • Sort: 
avatar image
-1
Best Answer

Answer by giulio-pierucci · Feb 15, 2015 at 11:25 PM

Set zero to gravity scale and disable Is Kinematic

http://docs.unity3d.com/Manual/class-Rigidbody2D.html

Comment
Add comment · Show 3 · 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 giulio-pierucci · Feb 15, 2015 at 11:43 PM 0
Share

I'm see the script move a quad right now. I have to set kinematic off, gravity 0 and $$anonymous$$enuy to false from inspector and the quad goes away

avatar image Xysch · Feb 16, 2015 at 02:23 AM 0
Share

Had all of that already set.

avatar image giulio-pierucci · Feb 16, 2015 at 08:29 AM 0
Share

This is my test package. And yet it moves movimenttest.zip

movimenttest.zip (5.6 kB)

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

19 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

Related Questions

Making a bubble level (not a game but work tool) 1 Answer

Distribute terrain in zones 3 Answers

Implement moveSpeed to this object script? 1 Answer

How to hold objects in third person? 1 Answer

How can i do: When the button "play"is pressed, the player can start to move, but if not pressed the player cannot move. 1 Answer


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