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 ThiagoTejo · Dec 27, 2013 at 01:51 AM · movementfpsjumpindependent

Movement FPS Independent, how to?

Hello people, I've already asked this here a few times, but no one awsered, so let's try again. I've made a Character controller myself, and I tought i did things right when it comes to FPS independency, but when I tessted in other machines, it does'nt seem so.

My code is pretty big. but the main lines are these:

 if(grounded == false) //Gravity for falling
 {finalmovement.y -= gravity * Time.deltaTime;}
 if(Input.GetButtonDown("Jump")) //Jumping
 {finalmovement.y = 7;}
 
 
 myTransform.position += (myTransform.rotation * finalmovement)*Time.deltaTime; //Overall movement

I tought it is ok, if my character is not on the ground, the gravity is applied with Time.deltaTime, and if I jump, the Y of finalmovement goes to 7 and then starts to go down with the gravity to make my character move downward.

But the problem is, when i have low fps, my character doesn't jump as high. why? It seems that the gravity is being applied more strongly ( I guess its because the Time between frames is bigger ), in other words, my movement is not FPS independent, even if I use Time.deltaTime. How can I solve this? Is my guess about the problem right? Thanks in advance.

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 ThiagoTejo · Dec 27, 2013 at 09:20 PM 0
Share

Can someone awser me? :(

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by sparkzbarca · Dec 27, 2013 at 02:01 AM

myTransform.position += (myTransform.rotation * finalmovement)

ok well this line above, i can't believe the compiler is even allowing such a thing

you have

vector3 += quanternion vector3 float

now vectors can be rationally multipled against floats (and probably quans too) but multiplying a vector3 against a quan is just wierd. a quan is 4 values a vector is 3 i've no idea how you logically compute that.

Irregardless remove the mytransform.rotation. There is no reason it should ever be in there that is causing wierd bugs and is probably your problem.

Also you probably should use fixed update for charactermovement not update. The thing is fixedupdate is where physics occurs, if you want to use colliders and things you want to use fixedupdate. That's just a suggestion though, my guess is removing the rotation will fix it.

Comment
Add comment · Show 10 · 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 ThiagoTejo · Dec 27, 2013 at 02:08 AM 0
Share

Well, you should read more about multiplying quads and vector 3... It's possible, and sorry, but it have nothing to do with my problem... Also, i'm not using unity physics for anything in my game, only for raycasting, i've made my own gravity and I detect if its grounded via raycast. Should I use FixedUpdate anyway?

Thanks for your awser.

avatar image sparkzbarca · Dec 27, 2013 at 02:11 AM 0
Share

can you explain why your rotation is modifying your position. I mean Unity stores those two as completely seperate variables for a reason. your basically saying I want the way im facing to decide where i am in space.

Your saying if i face forward i want to stand here but if i face left for example dont just rotate me in place but physically move my bodies position as well.

avatar image sparkzbarca · Dec 27, 2013 at 02:14 AM 0
Share

to answer your question, I think you should use fixedupdate or even possibly a coroutine at half fixedupdate. The thing is you probably dont need to actually be checking anything more than 30 times a second unless your are just going crazy fast.

But if you have a link or soemthing to where you got the idea to use rotation in your position, this just seems like a terrible idea. I can't imagine how the point in space that the center of your object should be located at would ever be affected by its rotation.

avatar image sparkzbarca · Dec 27, 2013 at 02:17 AM 0
Share

if you dont $$anonymous$$d me asking, does it work as you expect if you remove the rotation line?

avatar image ThiagoTejo · Dec 27, 2013 at 02:20 AM 0
Share

Actually, the quad doesnt modify the position by itself. It deter$$anonymous$$es wich direction the Vector3 it is multiplying is facing. I use this, so, when i want to make my character move forward, i add a number to finalmovement.z, and multiply it by the rotation of my character, so, finalmovement.z will became the direction my character is facing, you get it?

Also, I've tried putting these lines in Fixed Update, but it looked really bad, my character seems to be shaking, and the movement became very rigid.

Show more comments

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

Jumping increases movement speed 1 Answer

Why does this script make my camera jump when I move back? 1 Answer

How do I create WASD controls for a fps? 3 Answers

What is the best way to move a character for an FPS? 1 Answer

How can I get a responsive rigidbody FPS controller without acceleration that reacts to forces? 2 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