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 / Sprite Physics On/Off/Setting Values

Author
Message
thoromyr
7
Years of Service
User Offline
Joined: 14th Dec 2016
Location:
Posted: 16th Dec 2016 21:47
Doing a simple game using sprite physics and it appears that I've hit some undocumented features.

Specifically, if I set a sprite up for physics and use it and it dies I can make it invisible, turn physics off and all is good.

But, if I resurrect the sprite and re-enable physics then it starts with its previous physics velocity (linear and angular). No problem, right? You just set those to the desired values (zero, in this case). Nope, using SetSpritePhysicsVelocity() and SetSpritePhysicsAngularVelocity() are both ignored.

Hmmm... well, then... okay, instead of SetSpritePhysicsOff() I can use SetSpritePhysicsDelete(). After all, the documentation says you can use that to change the mode or shape so using SetSpritePhysicsOn() should restore physics to the sprite, right? Apparently not. Or, maybe you have to do more than just call SetSpritePhysicsOn() again?

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 17th Dec 2016 10:53 Edited at: 17th Dec 2016 11:03
Quote: "sing SetSpritePhysicsVelocity() and SetSpritePhysicsAngularVelocity() are both ignored."


i made a test, its not ignored.
AGK (Steam) V2.0.22 : Windows 10 Pro 64 Bit : AMD (16.12.1) Radeon R7 265 : Mac mini OS Sierra (10.12)
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 19th Dec 2016 14:42
Try setting a force inverse to the velocity to stop it, rather than trying to directly apply a velocity. (Because that's how physics works. )
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 19th Dec 2016 22:37 Edited at: 19th Dec 2016 22:46
naah, velocity is the result from a force with mass x all the time.
if it is set to zero the gravity will made a acceleration but nothing else. i think its not necessary to use a force as brake.
giving the velocity a value is more problematic (for collision system) because the acceleration is not simulated.

i guess the reason can be a mistyped sprite handle or the call order of commands.
AGK (Steam) V2.0.22 : Windows 10 Pro 64 Bit : AMD (16.12.1) Radeon R7 265 : Mac mini OS Sierra (10.12)
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 23rd Dec 2016 15:41
Without seeing code, we're shooting in the dark. My suspicion is you may be using the incorrect value sprite ID (a common mistake is to use the Image ID instead of the Sprite ID and can be tricky to spot if loading images and building sprites at the same time). Post some code highlighting the problem and we can help fix it.

V2 T1 (Mostly)
Phone Tap!
Uzmadesign

Login to post a reply

Server time is: 2024-11-24 22:51:09
Your offset time is: 2024-11-24 22:51:09