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 Diet-Chugg · Dec 25, 2010 at 10:00 AM · iphoneframerateipadtransitionchoppy

smooth transitions for Rigibodies objects on iPhone and iPad

Hi I have been trying to get smooth transitions for my objects with Rigibodies on the iPhone. I have tried making modification in the Time Manager and I got stuck. Right now everything seems to run choppy...

I also have a hero in my game and he runs choppy left and right too. Here's the movement part of the script:

private var moveDirection = Vector3.zero; function FixedUpdate() { MoveMent(); }

function MoveMent() { var controller: CharacterController = myTransform.GetComponent(CharacterController); moveDirection = Vector3.zero; fTravelDist = fTravelSpeed Time.deltaTime; if(sState == "MoveRight") { moveDirection = Vector3(fTravelDist,0,0); } else if(sState == "MoveLeft") { moveDirection = Vector3(fTravelDist-1,0,0);
} controller.Move(moveDirection); }

Thanks again for all the help. I am learning so much about unity and enjoying it the whole way along.

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

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

Answer by Peter G · Dec 25, 2010 at 01:10 PM

Character Controllers are not considered rigidbodies. I do not know if you have a rigid body on your object, but you should remove one if you have both.

Based on your movement script, the only problem I see is that you are calling your function from FixedUpdate() when you should be calling it from Update for 2 reasons:

  1. Update gives better performance than fixedUpdate hence FixedUpdate should only be used if you are using a rigidbody.

  2. You are multiplying your Speed by Time.deltaTime. Time.deltaTime is 1/FPS so you want a function that is called every frame such as Update(). Since Fixed Update is called a constant rate and Time.deltaTime varies, that is probably why you are getting stuttering. You could use Time.fixedDeltaTime if you insist on using FixedUpdate();


A few more random points to help your performance.

  • You should cache your CharacterController so that you do not have to find it every frame which is expensive. (see below)

  • You could inline your entire movement function. The compiler might do it anyway for you, but unnecessary function calls are not good. You might want to do some tests to see if there is any difference.


private var moveDirection = Vector3.zero; private var controller : CharacterController;

function Start () { controller = GetComponent(CharacterController); //Cache the controller }

function FixedUpdate() { MoveMent(); }

function MoveMent() {

 moveDirection = Vector3.zero;
 fTravelDist = fTravelSpeed * Time.deltaTime; 
 if(sState == "MoveRight")
 {
     moveDirection = Vector3(fTravelDist,0,0);
 }
 else if(sState == "MoveLeft")
 {
     moveDirection = Vector3(fTravelDist*-1,0,0);    
 }
 controller.Move(moveDirection);

}

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 Diet-Chugg · Dec 26, 2010 at 10:37 AM 0
Share

This has helped alot with speed thanks again. Question though. When you say inline the entire movement do you mean just no not have a function at all? Just put all the code in the Update?

avatar image Diet-Chugg · Dec 26, 2010 at 11:10 AM 0
Share

Also Sorry for not being too clear with my Question. So I have figured out how to use the profiler to get the stats of my game.

avatar image Diet-Chugg · Dec 26, 2010 at 11:11 AM 0
Share

cpu-player> $$anonymous$$: -160.4 max: 346.0 avg: 157.3 cpu-ogles-drv> $$anonymous$$: 0.9 max: 170.2 avg: 6.9 cpu-waits-gpu> $$anonymous$$: 0.1 max: 176.8 avg: 128.7 cpu-present> $$anonymous$$: 0.4 max: 166.7 avg: 11.1 frametime> $$anonymous$$: 14.9 max: 350.8 avg: 180.6 draw-call #> $$anonymous$$: 16 max: 18 avg: 17 | batched: 7 tris #> $$anonymous$$: 3212 max: 4185 avg: 3576 | batched: 1640 verts #> $$anonymous$$: 2240 max: 2744 avg: 2443 | batched: 836

avatar image Diet-Chugg · Dec 26, 2010 at 11:15 AM 0
Share

player-detail> physx: 1.4 animation: 0.0 culling 0.0 skinning: 0.0 batching: 0.1 render: 1.7 fixed-update-count: 1 .. 5 mono-scripts> update: 3.1 fixedUpdate: 0.0 coroutines: 22.4 mono-memory> used heap: 290816 allocated heap: 356352 max number of collections: 0 collection total duration: 0.0

So I am not sure what I should be trying to get for my stats and I am sort of getting what I should do to improve them. So I guess what and how to fix my stats to get an ok frame rate is what I am after.

avatar image Peter G · Dec 26, 2010 at 01:08 PM 0
Share

See this page. You appear to be taking the biggest hit from the GPU. Your CPU waited an average of 128.7 milleseconds for the GPU every frame. Also, your numbers are very far apart. $$anonymous$$ake sure you gave your game a few cycles to setup and s$$anonymous$$dy itself before you record any information. http://unity3d.com/support/documentation/$$anonymous$$anual/Optimizing%20Graphics%20Performance.html#iPhoneOptimizingGraphicsPerformance

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

No one has followed this question yet.

Related Questions

Low frame rate with only one texture on iPad 4 Answers

Poor fog performance on the iPad? 2 Answers

How to set the video-playback orientation (iPhoneUtils.PlayMovie) 2 Answers

iOS application in the settings panel 3 Answers

Detecting an iPhone app running on an iPad 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