Change the direction of gravity for one gameobject

Hey guys,

I have an idea for how to handle grenade tossing in my top-down twin-stick game, but I wanted to get some advice.

Most of my game is using kinematic-based collisions.

I would like the grenade to have a little bounce in it.

My idea is:

  1. Have my grenades use a dynamic collision object (at first)
  2. Have an invisible “floor” (kinematic collision object) that the grenade bounces off of, this “floor” would rotate with the player pivoting around
  3. The grenade would bounce for a second, then disable the dynamic collision object and switch to a kinematic one (so it stays stationary), before exploding.

So far, does that seem feasible?

The thing that I don’t think is possible, but maybe I’m wrong…

To pivot the “ground”, can I also pivot the gravity force?

So when my character is looking left or right, the floor would be beneath them, horizontally. The default gravity force would work fine in that situation and a grenade would bounce along that nicely.

image

However, if I rotate my player, and the floor collision object rotates, the force of gravity will still go down (red arrows), instead of against the rotated floor (blue arrows) - so my grenades would roll back down the hill toward the player.

image

Is there a way to have the gravity for the grenade rotate with the floor?

I hope that makes sense :slight_smile:

Thanks!