Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 /
This question was closed Sep 13, 2015 at 10:54 PM by Burton-kun for the following reason:

La domanda ha avuto risposta, è stata accettata la risposta giusta

avatar image
0
Question by Burton-kun · Aug 06, 2015 at 02:36 AM · c#gridmove

Grid Movement script correction

I found this Grid Movement script: http://wiki.unity3d.com/index.php/GridMove It works perfectly but there is something I would like to change. When i keep the button to move the player and then I leave it, the player keep moving for some tiles then stops. I want the script more sensible to the keybutton pression, with no delay. I'm new to scripting and I know very few about C#(I used the one written in C#). Can somebody help me?

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

1 Reply

  • Sort: 
avatar image
3
Best Answer

Answer by Eric5h5 · Aug 06, 2015 at 03:00 AM

Nothing at all to do with the script; change the input settings for the appropriate axes to get rid of the smoothing (gravity/sensitivity), so that the values return to 0 immediately.

Comment
Add comment · Show 6 · 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 Burton-kun · Aug 06, 2015 at 11:01 AM 0
Share

It works! Thank you so much.

avatar image imilanspinka · Aug 06, 2015 at 03:33 PM 0
Share

I would never think of this!

avatar image Burton-kun · Aug 13, 2015 at 08:22 PM 0
Share

I still have problem with this script.

 if (is$$anonymous$$oving) {
     GetComponent<Animation>().Play("Walking");
 }
     
 if (!is$$anonymous$$oving) {
     GetComponent<Animation>().Stop("Walking");
 }

I added these few strings to play and stop an animation due to the movement. The problem is that every step the player does, the animation start again. I just want the animation to loop while the player is moving and then stops when the player stops.. Also the movement is not fluid as it should be. When the object reaches the end position, there's a little pause that makes everything jerky, like even if I keep the button down, the movement it's not continuous. Least but not last, I used these strings to make the player face the direction is moving:

 if (Input.Get$$anonymous$$eyDown("w"))
          transform.forward = new Vector3(0, 0, 1);
      else if (Input.Get$$anonymous$$eyDown("s"))
          transform.forward = new Vector3(0, 0, -1);
      else if (Input.Get$$anonymous$$eyDown("a"))
          transform.forward = new Vector3(-1, 0, 0);
      else if (Input.Get$$anonymous$$eyDown("d"))
          transform.forward = new Vector3(1, 0, 0);

But it doesn't work properly 'cause the player turns in different position even if is moving. If I'm moving the player to the top and I push one of the setted keys, the player keep moving top but facing the wrong direction. I don't think this is the best way to do this. How can I fix these problems?

avatar image Radetic · Aug 13, 2015 at 09:33 PM 0
Share

@Burton-kun: To make it move correctly when combining directions, you should have a Vector3 direction, set it to zero at the beggining of your evaluation method (say for instance you do it on Update() as usual) and then sum those values you used to set transform.forward in your script

avatar image Radetic · Aug 13, 2015 at 09:36 PM 0
Share

@Burton-kun: also, you could use

Input.GetAxis("Horizontal") * Vector3.right

ins$$anonymous$$d of checking and setting values manually for $$anonymous$$eyCode.D and $$anonymous$$eyCode.A

Axis named "Vertical" will do the trick for W and S in the way. Since these are Unity'sdefault axis, they also work with the arrows in your keyboard

Show more comments

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Illuminating a 3D object's edges OnMouseOver (script in c#)? 1 Answer

Flip over an object (smooth transition) 3 Answers

Making a bubble level (not a game but work tool) 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