I have two questions/problems that I need to solve.
The first requires me to have a robot with a swinging “limb” that is affected by gravity and can collide with various objects. Basically it would be a hinge joint attached to a floating robot. So what I did was make the shoulder of the limb a hinge joint, and while this made it swing, it also fixed it’s world position. So I activated “Is Kinematic” and then it wouldn’t even swing. So how can I go about doing this in a manner that works?
The second problem is that I have a circular space station with artificial gravity pushing out from the center, or rather, it would have that gravity if I knew how to create it. Is there a way to make gravity push away from a certain centerpoint or centerline?
You want to have the Connected Body of the hinge joint be another object (in this case, the robot). Otherwise its position is fixed to the world, as you discovered.
That’s because any object that’s kinematic is totally under scripted control, and the physics engine pretty much ignores it.
As for your second question, I think there was a discussion about that somewhat recently…can’t remember where, but the short answer is no. The long answer is yes, but you have to apply forces to the objects individually rather than use a single gravity variable that automatically affects everything.
Actually, since the space station is spinning, I bet it WOULD work. Just turn off regular gravity, make sure the floor has friction so it “pulls objects along” as it spins, and let Sir Isaac Newton do the rest Am I crazy?
The amounts of friction/drag/inertia/mass, as well as the spin rate and radius of the wheel, would all have big effects on how well the result turned out.
Also, without friction, this would not work: so a hovering robot would need some invisible “pad” under it that contacted the “floor.”
wow… I’m going to have to test this. Also, theoretically, if the player character jumps, then they should end up running in to the wall either behind them or in front of them… since objects travel in straight lines, not circles. Hmmmmmmm…
Edit: I just realized that I’m going to need a way to initially “stick” the objects to the motion of the spinning circle… otherwise they’ll just sit there floating.
Second Edit: I thought there was a way to apply a force radiating from a point, like one would do with an explosion or some such thing.
The problem with using friction is that the objects have to make the initial contact with the floor in order for any sort of friction to affect things. So at an initial state, the objects are motionless, then they touch the spinning object and go flying out of control.
In a script, just apply a force with something like rigidbody.AddForce((transform.position - point) * scalingFactor) to have the object accelerate faster the further it gets from the specified point. In general, any form of arbitrary gravity can be simulated by applying forces in this way.
If it’s a space station spinning around its axis, you might want to use the closest point on its axis as the origin of the force instead of the centre of the space station, particularly if its shape is more like a cylinder than a wheel.
Well, what I’m making is a 3D side-scroller, the player exists in the middle third of the level’s “depth.” The monsters can exist anywhere, and the objects(like boxes and things) can exist anywhere. However, since the player is in the middle portion, having the objects slowly slide towards the front and back walls would actually be convenient.