Announcement

Collapse
No announcement yet.

Change objects gravity vector?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Change objects gravity vector?

    I have a vehicle that pretty much relies entirely on physics to "float", and it has the possibility of becoming out of control and tipping over and other unique features thanks to this. I want to keep these physics, but I want my vehicle to be able to continue to have these properties- while being able to driver perfectly up walls ( given the angle is ~>135 degrees; just a guesstimate that could be entirely wrong), ceilings , and any other surface. I came up with 2 possible solutions to keep this, however do not know how I could possibly actually do either- or if it even possible in Unreal Engine.

    A) change the direction of gravity for the object to be the opposite direction of the normal that is being hit by a raycast
    B) Manually apply physics to go into the opposite direction of the raycast hit normal, and somehow get the normal gravity vector to act as a *1.

    Currently, my vehicle works by applying a force to points (like vehicle suspension, and has 4 points), so simply driving up a while now will just push me off the wall thanks to the current gravity being negative Z on global. I don't want to change the global gravity, as I would like the option to later have multiple people, or other physics based objects in my game.

    #2
    You can change the gravity to a negative value if you just wanna invert the direction of gravity. If you wanna fake gravity (e.g. "pull" the vehicle up a wall or so) I would suggest to look into the SetPhysicsLinearVelocity - you can use that function every tick to adjust the "fake gravity" by your vehicle coordinates.
    My Patreon page (UE4 goodies!)

    Comment


      #3
      Option B
      manually applying -9.8 m/s^2 of force in the direction of the new floor, per tick "should" do the trick

      but remember, F = ma
      so the force will be the: weight of your car (in Newtons) X -9.8

      Unreal doesn't have anything in place for Non Z Gravity right now, afaik
      Last edited by Bankworthy; 02-14-2017, 11:09 AM.

      Comment

      Working...
      X