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 / Get Collision Kinetic Energy?

Author
Message
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 30th Aug 2021 03:32
I spent some time researching this and found a rather long and confusing blog about linear algebra and such and I came up with this



For the most part it works but I get a small inconsistency when 2 sprites are at a certain angle to each other (around 30 degrees) so it must be my code, pretty sure I am not handling the velocity's right inside the Sqrt(), should those be squared?
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 30th Aug 2021 05:05 Edited at: 30th Aug 2021 05:22
i can't help much here but from THIS "collision in 1 dimension", i don't see usage of SQRT but do see:
(0.5*M1*V1)^2 + (0.5*M2*V2)^2 = Joules (how to convert to AppGameKit from there, i dunno - update, i get it now (somewhat) = N m).

what exactly is "wrong" or inconsistent? is it apparent in your last project update?

also, be careful with the built-in Round function. dunno if it's related to the undesired results but take note.
[My Itch.io Home] [Community Apps on Itch.io]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=agk] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[AGK Showcase][Google Forum Search]
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 30th Aug 2021 05:44
Yes, 16 seconds in I try to merge 2 sprites and they bounce off each other, my kinetic threshold is set to 1000, in other instances when merging at the same distance its fine just the odd occasion the impact threshold is not met (at that range it should or is usually around 1800)

maybe I need to increase my acceleration multiplier at close distances, Ill do a proper log and debug tomorrow and see if I can pin it down, at the forces involved I doubt the rounding error makes a difference to be honest, mass is high and speeds are fast a floating point error would not even register
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 30th Aug 2021 05:50 Edited at: 30th Aug 2021 05:51
a) I wouldn't round it
b) How do you apply the result?
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 30th Aug 2021 07:33
The result is simply checked in a if statement (if force>1000) then allow the merge action to take place, else low speed collisions do not merge, I did it this way because allowing all sprites to merge on all collisions was just to erratic and pretty much unplayable the whole thing needed to be slowed down and managed.

Virtual Nomad wrote: "how to convert to AppGameKit from there, i dunno"


That's pretty much the same calculation I was working from, blackboard algebra, and that function above is the best I can interpret from what I was reading.

I will make it spit the data out to file when I start coding again and examine it that way, there is a lot going on in the moment the left button is lifted and the sprites meet, tweens played, animations set, several states switched etc etc, I think the function ^^ is sound, it never happens with sprites at a distance only those at close proximity so I might be bug checking the wrong function, I calculate the acceleration multiplier based off the distance so the merges look consistent and all contacts should be a relative linear velocity and mass therefore comparable kinetic energy no matter the distance, like I say for the most part I get the expected result, just that oddball random case seen in the video.
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 30th Aug 2021 19:45
Update: I'm an idiot!

Turns out my issue was a dampening, I had to dampen the atoms as they were created (again, was way to erratic) and it was still applied when merging thus reducing the impact force.
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee

Login to post a reply

Server time is: 2024-11-24 05:16:03
Your offset time is: 2024-11-24 05:16:03