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 BentoAUS · Apr 07, 2020 at 07:35 AM · scripting problemplatformer

Need some help with a platformer player script

I'm trying to learn to make a 3D platformer using a book I got, and so far I've followed it to make a functioning player control script, but it seems like it doesn't teach me some other things I'd like to do.

  1. I'd like the player character to face the same direction they're moving in instead of only being able to face forward. And then once they stop moving I'd like them to still face the direction they were last moving in.

  2. I'd like to edit the dash so upon first pressing the key you dash a set distance without having to hold down the key, so you can just press the key to do a dash move but you can also hold the key down to keep dashing.

  3. I need the player to not be able to double jump in the air. The book I read had a part on this which I tried following in my script, but the character can still jump a little bit in the air, like it's a small jump like there's gravity weighing them down but it still needs to be fixed so you can jump again at all in the air.

I hope my words are easy to understand, I have trouble describing technical things.

 {
     public float Speed = 5f;
     public float Dash = 7f;
     public float Jump = 20f;
     public bool gc = false;
     public bool GroundTouch = false;
     public Text countText;
     public Text winText;
     private int count;
     private int SetCountText;
     float DashDistance = 2;
 
     // Start is called before the first frame update
     void Start()
     {
         {
             gc = true;
             count = 0;
         }
     }
 
     private void FixedUpdate()
     {
         if (Input.GetKey(KeyCode.W))
         {
             transform.position += Vector3.forward * Time.deltaTime * Speed;
         }
         if (Input.GetKey(KeyCode.A))
         {
             transform.position += Vector3.left * Time.deltaTime * Speed;
         }
         if (Input.GetKey(KeyCode.S))
         {
             transform.position += Vector3.back * Time.deltaTime * Speed;
         }
         if (Input.GetKey(KeyCode.D))
         {
             transform.position += Vector3.right * Time.deltaTime * Speed;
         }
         if (Input.GetKey(KeyCode.Space))
         {
             transform.position += Vector3.up * Time.deltaTime * Jump;
         }
         if (Input.GetKey(KeyCode.W) && (Input.GetKey(KeyCode.LeftShift)))
         {
             transform.position += Vector3.forward * Time.deltaTime * Dash;
         }
         if (Input.GetKey(KeyCode.A) && (Input.GetKey(KeyCode.LeftShift)))
         {
             transform.position += Vector3.left * Time.deltaTime * Dash;
         }
         if (Input.GetKey(KeyCode.S) && (Input.GetKey(KeyCode.LeftShift)))
         {
             transform.position += Vector3.back * Time.deltaTime * Dash;
         }
         if (Input.GetKey(KeyCode.D) && (Input.GetKey(KeyCode.LeftShift)))
         {
             transform.position += Vector3.right * Time.deltaTime * Dash;
         }
 
         Vector3 gc = transform.TransformDirection(Vector3.down);
         if (Physics.Raycast (transform.position, gc, .5f))
         {
             GroundTouch = true;
         }



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

0 Replies

· Add your reply
  • Sort: 

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

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

Need to restrict "air control" 2D platformer. 1 Answer

Bullet Script Problem 2 Answers

how d you change PlatformEffector2D rotationaloffset change as prefabs in android? 0 Answers

Need help accessing booleans from other script. 2 Answers

How to make a companion that trails character moves, and not collide? 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