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 Ozale · Apr 11, 2011 at 02:22 AM · movegridincrement

Movement by increment jerkiness

G'day guys,

I'm building a maze-collection game, and using a multidimensional array for movement (that's what [rowIndex] and [colIndex] deal with). My issue is a slight 'jerk' at each new 'grid'. I understand, from looking at a similar system that was put up on the scripts wiki ( http://www.unifycommunity.com/wiki/index.php?title=GridMove ), and I notice the line:

"tx = t - 1.0; // Used to prevent slight visual hiccups on "grid lines" due to Time.deltaTime variance"

I believe this refers to what I'm noticing. What's more, is it isn't noticeable on all machines, as I believe it's caused by frame rates, it'll only be visible on slower frame rates.

Here's a sample of how I'm moving things (this is only for West, each direction has a different IF statement).

else if (actualBearing == 'West' && (grid[rowIndex][colIndex-1]) == 1) { west = true; moving = true; startPosition = transform.position; endPosition = transform.position + Vector3.right * stepDistance * -1; stepStartTime = Time.time; pivot() ; colIndex = colIndex-1; junction = true; realBearing = 'West'; } }else { var progress: float; progress = (Time.time - stepStartTime) / stepTime;

     if (progress >= 1.0) {
         transform.position = endPosition;
         moving = false;
     } else {
         transform.position = Vector3.Lerp(startPosition, endPosition, progress);
         pivot() ;

     }
     progress = progress -1.0;
 }

Does anybody have an idea what's causing this?

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
0

Answer by Eric5h5 · Apr 11, 2011 at 04:11 AM

It's because the object's position is set to "endPosition" when it finishes moving, then it's set to "startPosition" (which is the same as the previous endPosition) for the next move, so it has the exact same position for two frames in a row. The more frames per second you have, the less noticeable this is, but the code in the GridMove script prevents that from happening in the first place. I'd recommend using that code for movement and applying the multidimensional array stuff on top, since having separate if statements for each direction is less than ideal (it's harder to maintain and more bug-prone than just having one set of code for movement).

Comment
Add comment · Show 1 · 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 Ozale · Apr 11, 2011 at 05:08 AM 0
Share

Cheers, I'll try fixing it myself. I didn't want to use Gridmove because this is my first 3D game project, and first game using JavaScript. I'd rather learn myself, you see, and there's no educational gain copy+pasting a prebuilt system, y'know?

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

Help with Grid Movement 2 Answers

Limit MoveTowards for one step at a time movement 3 Answers

How to Move an Object down until a certain point then activate a function 1 Answer

Falling through terrain with Grid Move Script 0 Answers

Can't figure out how to achieve an effect like QUBE 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