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 / [SOLVED] Sprite Gravity

Author
Message
george++
AGK Tool Maker
16
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 29th Jun 2020 22:25 Edited at: 29th Jun 2020 22:32
Hi.
How to set a physics sprite which won't be influenced by the gravity?
It seems that setting the mass to 0.0 has no effect

The author of this post has marked a post as an answer.

Go to answer

fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 30th Jun 2020 00:08
This post has been marked by the post author as the answer.
I don't believe there is a way apart from SetPhysicsGravity( 0,0 ) which effects all the physics sprites

fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 30th Jun 2020 00:29 Edited at: 30th Jun 2020 00:45
Apply a force equal to gravity but in the opposite direction.
Or SetSpritePhysicsOn(sprNo, 3)
george++
AGK Tool Maker
16
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 30th Jun 2020 16:00 Edited at: 2nd Jul 2020 10:06
Thank you both. Your answers are totally different, and to the right direction, to what I found through the web search.

I work on a platform project and I need to create bullets, that will collide with static and dynamic bodies.
Quote: "Apply a force equal to gravity but in the opposite direction."


This is my gravity setup

Do you know how to calculate the opposite force in order to reverse the gravity? Will it apply in every physics step?. I use
and I don't know if it matters

Quote: "Or SetSpritePhysicsOn(sprNo, 3)"

Then the bullet will not collide with static objects

Quote: "I don't believe there is a way apart from SetPhysicsGravity( 0,0 ) which effects all the physics sprites"

I think I'll go with this solution and I'll simulate gravity to specific objects. Still don't know how to apply a force for this simulation. I mean do I have to apply a force in every physics step or what?
george++
AGK Tool Maker
16
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 30th Jun 2020 16:56 Edited at: 2nd Jul 2020 10:04
It was simple.
I followed Scraggles advice and I simply used the SetSpritePhysicsForce function within the main loop

Login to post a reply

Server time is: 2024-04-20 06:11:49
Your offset time is: 2024-04-20 06:11:49