playMaker

Author Topic: Gravity  (Read 1420 times)

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • View Profile
    • Homepage
Gravity
« on: September 06, 2014, 06:07:28 PM »
Is it possible to have both normal gravity "Y -20" and gravity the other way like "Y 20" at the same time? For example if I have a character on the ground and a character on the roof.
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

cloud03

  • Full Member
  • ***
  • Posts: 230
  • Viva Playmaker!
    • View Profile
    • Milkish Game Studios Blog
Re: Gravity
« Reply #1 on: September 06, 2014, 06:53:01 PM »
With 2D Rigidbody is quite easy to do this, you can set the gravity scale to a negative value, but with 3D Rigidbody there is no option to change the gravity scale. One way to do this by adding a constant force component to the GameObject, and insert a value on the y-axis to be greater than the gravity (ex: 19.6 , from 9.8 multiply by 2). I'm not sure is this actually physically correct, but I've tested it, and it does the job...

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2487
  • Yup.
    • View Profile
    • Cleverous
Re: Gravity
« Reply #2 on: September 06, 2014, 08:37:30 PM »
Gravity is just a force of 9.81 on all rigidbodies on -y. Double it and push to +y and you'll have inverted gravity on select bodies. Basically like cloud described.

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • View Profile
    • Homepage
Re: Gravity
« Reply #3 on: September 07, 2014, 02:22:37 AM »
Hi!

I can't have 2D Rigidbody on capsule. Does it need to be a flat 2D object?

Did you try with two objects at the same time, Cloud?
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

cloud03

  • Full Member
  • ***
  • Posts: 230
  • Viva Playmaker!
    • View Profile
    • Milkish Game Studios Blog
Re: Gravity
« Reply #4 on: September 07, 2014, 02:53:09 AM »
yup, I've tested with two objects simultaneously, and it worked...here is the scene example..

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • View Profile
    • Homepage
Re: Gravity
« Reply #5 on: September 07, 2014, 03:37:20 AM »
Thank you! I need to have a higher value on Constant Force, because one cube will be on the ground and the other cube will be on the roof. I didn't know about Constant Force, so thank you for that. :)

But I tried with add force also and checked every frame and that worked also very good. The ground object has Add Force -10 and the roof object has Add Force 10. :)
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no