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 goo-muffin · Jan 20, 2013 at 10:22 PM · cameraplayerfpsjumpwalking

standard fps walking script makes me faster when jumping

Hi!

When I'm jumping with this script, it makes me go faster forward when I'm jumping, is there a way to avoid this?

 var Walkspeed = 6.0;
 var speed = 6.0;
 var jumpSpeed = 8.0;
 var gravity = 20.0;
 var cameraObject :GameObject;
 private var moveDirection = Vector3.zero;
 private var grounded : boolean = false;
 
 function Update() {
     transform.rotation = Quaternion.Euler(0, cameraObject.GetComponent(look).currentYRotation, 0);
     speed = Walkspeed;
     if (grounded) {
 
 
         // We are grounded, so recalculate movedirection directly from axes
         moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
         moveDirection = transform.TransformDirection(moveDirection);
         moveDirection *= speed;
 
         if (Input.GetButton ("Jump")) {
             
             moveDirection.y = jumpSpeed;
         }
     }
     // Apply gravity
     moveDirection.y -= gravity * Time.deltaTime;
 
     var controller : CharacterController = GetComponent(CharacterController);
 
     var flags = controller.Move(moveDirection * Time.deltaTime);
     
 
     grounded = (flags & CollisionFlags.CollidedBelow) != 0;
 
 
 }
Comment
Add comment · Show 4
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 Owen-Reynolds · Jan 20, 2013 at 10:42 PM 0
Share

Why do you say it makes you faster?

Your sideways x/z speed should be exactly the same in the air as the ground, which is easy to program, wrong according to real-life, but correct for video games (when you run, you have to make little jumps so you don't get stuck on the terrain, which don't affect your speed.)

Is your terrain really bumpy -- the would slow down ground speed, as it should.

Are you printing rigidbody.velocity? That will be faster, but only because of y. The "flat" x/z part is still the same.

avatar image sparkzbarca · Jan 21, 2013 at 03:29 AM 0
Share

im with him, your not, i was going to ask myself how the hell you knew.

avatar image goo-muffin · Jan 21, 2013 at 03:00 PM 0
Share

well the problem is my "terrain" is a flat ground... so this is a bit tricky... btw. my values are 6 / 4 / 5 / 14

avatar image sparkzbarca · Jan 21, 2013 at 05:34 PM 0
Share

what values are?

Basically were pretty positive your not actually speeding up.

if your using velocity to deter$$anonymous$$e that. for example if that 6/4/5/14 is 4 different velocities thats ok.

velocity is the sum of your speed in 3 axes.

if you start out going 1 mph in the x direction and 1 mph in they z direction. and you jump and your going 2 mph in the y direction. Your velocity might be 4 but forward movement is only 2 still.

if you'd like to know your speed with regard to forward motion print out velocity.x and velocity.z

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

11 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

Related Questions

FPS camera wiggle as character walks 1 Answer

Make object visible only for camera "X" 1 Answer

Make so that a player cant see the players model? 1 Answer

DontDestroyOnLoad() Unity 3D 0 Answers

Network fps swap cameras 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