Game Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesGame Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 1st, 2012, 05:05 AM
kapesu8 kapesu8 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2012
Posts: 3 kapesu8 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 17 m 24 sec
Reputation Power: 0
Unhappy How would I move an object smooth and fast?

So lets say I have unit vector 'a' as direction.
To move an object to the direction I would use
object.Position=object.Position + a*speed, right?

If the speed would be something like 5 it would just teleport 5 units towards the direction..

I could use some loops to move it and keep the speed under 1 unit..But..

That's slow since the smallest sleep would be the time from frame to another frame.

I can't get an object to move smooth and fast...

Reply With Quote
  #2  
Old April 1st, 2012, 08:32 AM
MrFujin's Avatar
MrFujin MrFujin is online now
Lord of the Dance
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Oct 2003
Posts: 3,130 MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 23 h 48 m 21 sec
Reputation Power: 1736
To get something smooth, you should have at least 30 frames per second (fps) and higher is better.

You say you want to move it fast with 5 unit in speed, but speed is defined by the distance over a specific time.

You have to ask if the speed should be 5 unit/frames directly or 5 unit/second.
If you want to work with seconds, you will then have to calculate the unit/frames, depending at the fps.

e.g. 5 unit/second with 30 fps will have the actual frame speed at 0,16 unit.

Reply With Quote
  #3  
Old April 2nd, 2012, 12:32 PM
kapesu8 kapesu8 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2012
Posts: 3 kapesu8 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 17 m 24 sec
Reputation Power: 0
Question

Quote:
Originally Posted by MrFujin
To get something smooth, you should have at least 30 frames per second (fps) and higher is better.

You say you want to move it fast with 5 unit in speed, but speed is defined by the distance over a specific time.

You have to ask if the speed should be 5 unit/frames directly or 5 unit/second.
If you want to work with seconds, you will then have to calculate the unit/frames, depending at the fps.

e.g. 5 unit/second with 30 fps will have the actual frame speed at 0,16 unit.


So..
Some-kind of a loop with smallest sleep and;
position = position+direction*0.16

?

Reply With Quote
  #4  
Old April 2nd, 2012, 01:31 PM
MrFujin's Avatar
MrFujin MrFujin is online now
Lord of the Dance
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Oct 2003
Posts: 3,130 MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 23 h 48 m 21 sec
Reputation Power: 1736
Try it and see how it looks.

But if you only have that calculation in a loop, it will go much faster than the "5 unit/second".

For example, in my test, it takes about 5 milliseconds to get from 0 to 5 with a step at 0.16 while it prints out "Hello World". (tested with Java)

But this is of course without any use of sleep "cheating"

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesGame Development > How would I move an object smooth and fast?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap