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 / [2D physics] request to make the reaction to a force for SetSpritePhysicsAngularImpulse() and SetSpritePhysicsTorque() relative to the object's mass instead of its size

Author
Message
Scary Little Rabbit
14
Years of Service
User Offline
Joined: 4th Aug 2009
Location: Chelyabinsk, Russian Federation.
Posted: 20th Jul 2019 00:11 Edited at: 26th Jul 2019 22:58
...like it is for SetSpritePhysicsForce() and SetSpritePhysicsImpulse().

it seems impossible for me to keep same aspect ratio of a sprite on all devices keeping it not stretched anyhow with default percentage based system - because of various aspect ratios of displays - and so sprite's size cannot be the same across devices. (usually I keep only sprite's height myself.)

also I don't know how to calculate precise multipliers to rotate sprites with different sizes with the same angular speed via said commands.

some code:
error #1:
'too many stars, too many stares. disembody.'
Lone Star Dive: Fears of Mars
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 22nd Jul 2019 21:34
it should already but the default mass is changed with the scale of the sprite so you would need to set some values yourself if you want to override it - SetSpritePhysicsMass( iSpriteIndex, mass )
life's one big game
spec= i5 4ghz, 16gb ram, Nvidia 1070ti gpu
Scary Little Rabbit
14
Years of Service
User Offline
Joined: 4th Aug 2009
Location: Chelyabinsk, Russian Federation.
Posted: 25th Jul 2019 01:34
smallg, create a pair of sprites with different sizes and set the same mass to see you are not right
error #1:
'too many stars, too many stares. disembody.'
Lone Star Dive: Fears of Mars
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 25th Jul 2019 05:45 Edited at: 25th Jul 2019 05:48
SLR,

Re: Mass, it might be "order-related"; see HERE.

Note where the order of the 2 commands are flopped which caused issue:



worth a shot?

Scary Little Rabbit
14
Years of Service
User Offline
Joined: 4th Aug 2009
Location: Chelyabinsk, Russian Federation.
Posted: 26th Jul 2019 20:18
Virtual Nomad wrote: "worth a shot?"
not on my machine unfortunately. I've added some code to play with, see the first post.
error #1:
'too many stars, too many stares. disembody.'
Lone Star Dive: Fears of Mars
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 28th Jul 2019 19:03 Edited at: 28th Jul 2019 19:47
so what are you seeing with the above code?
for me it looks like they all rotate around the same speed due to your modifiers, i assume you want them to all rotate the same speed without the modifiers?
but yes it does appear 2D physics ignores mass for rotation, its shouldn't but there we go

edit; this is the only way i could see to get it to work as expected - basically made the shape the same for all sprites and then made the density of their real shape have 0 weight.
life's one big game
spec= i5 4ghz, 16gb ram, Nvidia 1070ti gpu
Scary Little Rabbit
14
Years of Service
User Offline
Joined: 4th Aug 2009
Location: Chelyabinsk, Russian Federation.
Posted: 29th Jul 2019 00:00
smallg wrote: "2D physics ignores mass for rotation, its shouldn't"

that's my point.

smallg wrote: "made the shape the same for all sprites and then made the density of their real shape have 0 weight"

oh, I see. it's a nice workaround.
but what about collisions, does it take external (bigger) shape for that and keep it moving according with properties of inner (smaller) one?
error #1:
'too many stars, too many stares. disembody.'
Lone Star Dive: Fears of Mars
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 29th Jul 2019 14:03
it does collide properly with the larger shape but as for how it reacts... not sure, would assume it uses the smaller shape as the larger one shouldn't have any mass - i only did a real quick test with a tiny object to make sure the larger shape still had a "physical" presence.
life's one big game
spec= i5 4ghz, 16gb ram, Nvidia 1070ti gpu

Login to post a reply

Server time is: 2024-04-19 10:55:10
Your offset time is: 2024-04-19 10:55:10