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 Studio Chat / Linear Velocity Formula

Author
Message
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 13th Apr 2019 11:35
Hello Community,

I am trying to throw an object from the camera's position to in front of it, but I am stuck at the formula for this operation. Did someone encountered this problem and can help me?

Here is the code that I am trying to create:



Thank you!
www.alexmatei.com
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 13th Apr 2019 13:37 Edited at: 13th Apr 2019 13:41
where is the object before you do the calculation and are you deleting the physics body so you can manually move it?
this works for me
(you don't really need to delete the box physics shape if you are creating it again in the same frame as creating a new shape should delete the old one anyway but i add it just in case)
life's one big game
spec= i5 4ghz, 16gb ram, Nvidia 1070ti gpu
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 14th Apr 2019 16:56
smallg,

Thank you for your example! It works for me, with this method. I tried moving the object a bit down, but it doesn't let me. In your code works fine, but code looks like this:



Do you see any problems?

Thank you!
www.alexmatei.com
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 18th Apr 2019 09:01
*BUMP*

Sorry!
www.alexmatei.com
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 18th Apr 2019 13:04 Edited at: 18th Apr 2019 13:07
what do you mean by moving it a bit down?
it's starting location?
you set that with SetObjectPosition(slotonepickupweapon, xtwo, ytwo, ztwo), i set it to the camera location but if you want it to start a bit lower then lower ytwo


if you want it to travel downwards faster then you have already done that by changing the MoveObjectLocalY() value down but if you go below 0 it may start going back upwards in velocity when you calculate ytwo-yone so you'll want to check for that perhaps
life's one big game
spec= i5 4ghz, 16gb ram, Nvidia 1070ti gpu
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 21st Apr 2019 11:25
Your code works well, but I still don't know what I've missed.

I adapted your code into mine and it looks like this:



You can see the problem that I am talking about, here:

[video=youtube]https://www.youtube.com/watch?v=CPWWteI9_W8&feature=youtu.be[/video]

You see that it's too high, or I am just unable to see that maybe it starts from the correct position and its only propels itself too high?

Thank you again!
www.alexmatei.com
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 21st Apr 2019 13:38
you need to adjust in a better ratio to make the arc more smooth
MoveObjectLocalY(slotonepickupweapon, 15)
MoveObjectLocalZ(slotonepickupweapon, 15)
maybe something like
MoveObjectLocalY(slotonepickupweapon, 5)
MoveObjectLocalZ(slotonepickupweapon, 15)
would work better
life's one big game
spec= i5 4ghz, 16gb ram, Nvidia 1070ti gpu
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 22nd Apr 2019 14:36 Edited at: 22nd Apr 2019 14:52
What about this?

speed# is just the force of the line being thrown.
Timer is how much time has passed. Gravity is self-explanatory.


y# = (speed#*timer#)+.5*(gravity#*pow(timer#,2))

MoveObjectLocalZ(obj,speed#) // I think you would need to make the object face the correct direction here before applying this command
moveObjectLocalY(obj,y#)
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 24th Apr 2019 09:44 Edited at: 24th Apr 2019 10:17
I don't know... how does it look?

www.alexmatei.com
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 24th Apr 2019 09:58
to embed the above video use the
video tags button and place "5cZabN1GPxk" inbetween
fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 24th Apr 2019 10:17
Got it!

Thank you!
www.alexmatei.com
Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 24th Apr 2019 16:58
I don't know much about the built in physics, but if you want to do it programmatically you can view my example on projectile motion.
https://www.zimnox.com/resources/articles/math/?ar=m002#13
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 27th Apr 2019 07:50
I'll have a look, Phaelax!

Thank you!
www.alexmatei.com

Login to post a reply

Server time is: 2024-03-29 09:55:11
Your offset time is: 2024-03-29 09:55:11