playMaker

Author Topic: How do you add "Gravity" and "Force" without using rigidbodies?  (Read 7755 times)

Disastercake

  • Full Member
  • ***
  • Posts: 101
  • www.disastercake.com
    • Disastercake
I really don't like working with the quirky physics engine for Unity when making my 2D action adventure side-scroller.

Here is a list of needs that conflict with the way Unity's engine works:
1. I need some characters to fall normally and others to float
2. I need to dynamically change the gravity or certain objects so they can fall or float mid-application
3. I do not want the characters to physically push each other
4. I want an easy way to move characters like with transform
5. I need to have a sudden change in force that can project enemies away or suck them in, like a magnet type skill or an explosion that pushes people away.

Because of these requirements, I feel that a full blown physics engine like Unity will make the simple things I need complicated and quirky to work with, but I still need a psuedo type of physics going on with gravity and force (falling, jumping, and explosions pushing backwards).

What is the best way to handle these requirement without having to deal with the complexity of restrictions and quirkiness the default physics engine comes with?
Soul Saga - Anime themed adventure RPG by Disastercake

http://www.disastercake.com

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How do you add "Gravity" and "Force" without using rigidbodies?
« Reply #1 on: June 04, 2012, 03:03:28 AM »
Hi,

You'll definitely have to deal with the physics engine I am afraid :) because your requirements would simply mean writing a physics engine yourself... :)

now, yes physics can be difficult to get right, but I encourage you not to loose faith, and keep trying because it's only a matter of settings and tweaking.

1: this is easy, and not in contradiction with the engine, you simply switch physics settings to achieve this. for example, when the character need to float you attach it to a different rig, maybe a spring joint or simply switch off the gravity and increase the drag so that it drifts nicely.

2: do change the mass and i will affect the behavior under gravity.

4: to easily move a character, it really depedns what you are after, but setting a rigid body to "kinematic" will allow you to move it like any other non physics gameObject, else you can do like point 1, attached a sprring or joint and move the primar target and let the joint pull and push your character to follow that.

5: there is a system for this, explosion, I am about to release the shooting game from m2h and it uses explosive forces, so you'll have a working sample.

Now, to constraint all this into a 2d, there are ways, you can constraint one axis for each of your objects for example.

Have you worked with the various 2d frameworks available on the asset store, they are a lot of 2d games using physics, this would give you some working examples to learn from.


Bye,

 Jean