Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / 3D Aiming path

Author
Message
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 28th Oct 2018 04:41 Edited at: 28th Oct 2018 04:45
I am trying to show the projected path a ball in flight will take.
I currently do this by creating an invisible ball, applying linear velocity and tracking it until it passes a certain point.
My problem is it takes too much time. Not the processing but waiting for the number of frames to draw the path.
It look slows and laggy.
Anyone have any ideas on how to do this faster/better?

blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 28th Oct 2018 07:24
Trying to fudge it.
The key variables here are aim.speed aim.friction and aim.gravity.
It could be anything but i think my crude gravity calculation is not correct.
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 28th Oct 2018 12:10
I found these to be useful.

https://www.leadwerks.com/community/topic/13468-parabolic-arc-throwing-a-grenade/

Finding the vertex of a parabola:

https://www.varsitytutors.com/hotmath/hotmath_help/topics/vertex-of-a-parabola

Unity tutorial with code:
https://www.youtube.com/watch?v=ddakS7BgHRI
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 28th Oct 2018 19:17 Edited at: 28th Oct 2018 20:21
Thanks for that info Golelorn. Very interesting stuff

For my purposes it's working. I changed the gravity and it seems to give me a consistent result. I'm sure the longer the path the less accurate it will be (It is already not very accurate but good enough for a game i think)

These are the calculations;
1. Speed / 31.5 (From the SetObject3DPhysicsLinearVelocity() function)
2. Friction * 1.99 (From the GetObject3DPhysicsFriction() function)
3. Gravity * .035 (From the Set3DPhysicsGravity() function, Default is -10)



Attachments

Login to view attachments
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 29th Oct 2018 08:57
Could you step the physics in a loop without sync until you reach the end of the path (either a max length or hitting the wall) while saving the position data?
Then draw the path based on the saved data and sync.
I'm not sure it would work with physics as it should require a fixed update rate to keep it consistent but might be worth a try... Would certainly be good for if you needed bounces and such.
life's one big game
spec= 4ghz, 16gb ram, AMD R9 2700 gpu
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 29th Oct 2018 09:57 Edited at: 29th Oct 2018 09:57
I tried that but the problem was the Step3DPhysicsWorld() function is time based so it is still slow because you have to wait for the time to elapse so the object can move (If that makes any sense)

Login to post a reply

Server time is: 2024-04-26 21:02:06
Your offset time is: 2024-04-26 21:02:06