I’m trying to make a puzzle game where, depending on the color of the object, it is pulled towards a different wall in the room. (I don’t need to test for the color, I’m doing that part manually.) For example, green objects are affected by normal gravity, while blue ones are pulled in the negative x direction.
I need a script I could apply to any object to replicate gravity in a specific direction, such as a BlueGravity script for mimicking gravity in the x direction.
I can’t just set gravity to that direction, as various colors will be present simultaneously.
I would need to replicate an acceleration due to gravity, as well as replicating a collision correctly (right now, my failed attempts have the object still accelerating while colliding with a wall, so that when the wall disappears it continues at high speeds rather than resetting from zero like it should).
The cubes also need to be able to be carried and activate pressure switches, but that’s for another time and not the focus of this question.
How would I be able to do this? I need a BlueGravity and RedGravity (z direction) script, although I can simply make one based on the other. Green gravity can just use Unity’s gravity, I don’t need to over complicate at the moment.