Get the "Speed" of an object Forum Home > Construct 2 General > How do I....? |
Post Reply
|
| Author | |
Post Options
Quote Reply
Topic: Get the "Speed" of an objectPosted: 03 Nov 2011 at 3:11pm |
|
|
I am looking to get the speed of an object with physics being shot out of a cannon and cant seem to work it out, here is a capx of the general idea, any help would be greatly appreciated.
http://dl.dropbox.com/u/47975195/Speedofball.capx |
|
![]() |
|
Post Options
Quote Reply
Posted: 03 Nov 2011 at 4:46pm |
|
|
3DGS,
Speed = Distance/Time, so you need to determine the distance traveled by the cannon ball in a specific period of time, like every tick. Here is a modified capx: http://dl.dropbox.com/u/38038537/Speedofball_modified.capx This was just a quick and dirty example, and I'm sure there must be a more elegant solution (perhaps even built-in). |
|
![]() |
|
Post Options
Quote Reply
Posted: 03 Nov 2011 at 7:14pm |
|
|
thank you, that helps alot!
|
|
![]() |
|
Post Options
Quote Reply
Posted: 03 Nov 2011 at 8:04pm |
|
|
The physics expressions 'velocity x' and 'velocity y' are probably what you are looking for. I am not sure how to combine them to give you a good indication of actual velocity but it can't be that hard (most of the people hare are maths geniuses anyway ;) )
|
|
![]() |
|
Post Options
Quote Reply
Posted: 03 Nov 2011 at 8:54pm |
|
|
distance(0, 0, velocity_x, velocity_y)
will give you the speed. angle(0, 0, velocity_x, velocity_y) will give the direction. |
|
![]() |
|
Post Options
Quote Reply
Posted: 03 Nov 2011 at 9:26pm |
|
|
See? I knew there would be a more elegant solution.
Here is the capx again, with R0J0's information: http://dl.dropbox.com/u/38038537/Speedofball_modified.capx |
|
![]() |
|
Post Options
Quote Reply
Posted: 04 Nov 2011 at 12:00pm |
|
|
awesome thank you guys for the help i am really enjoying this program, and the community!
|
|
![]() |
|
Post Options
Quote Reply
Posted: 10 Aug 2012 at 5:10pm |
|
|
This is exactly what I was looking for, thank you. I never thought of using velocity like that. Totally makes sense.
|
|
![]() |
|
Post Reply
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |