Lock an object to the surface of another and a game concept disscusion


This OP contains a question and a game concept to discuss. Plus a gravity script with a demo.

The question:

Is there way to make an object lock (not to gravitate) to the surface of another object? The bumper cars for an analogy.
I’ve got a gravity script, but decision to use gravity gives extra problems with the Player movement and camera tracking.
I need a solution for a sphere, a cube and a plane. The problem is solved if a controlled thing doesn’t get stuck in edges, can move without a rotation and can’t fly down.

The concept:

There’s a mesh and two players start at opposite “poles” of it (on two sides of a plane, a cube, a mushroom, whatever).
Player moves on the surface(s) of the mesh, trying to find the other player and shoot him.

I offer to discuss variants of it. Also I offer to everyone pick it up and try to play with this concept or just to tell in which way you think it should be done.
Let it be the first question:
How the Players move, like a car, without ability to stop or take a sharp turn, or no?

Materials
The gravity script and the demo by Goran Milovanovic:


def apply(cont):
            cube = cont.owner
            for o in cube.scene.objects:
                       normal = o.rayCast(self, o)[2]
                       if not normal: continue
                       g = -normal * 9.8
                       o.applyForce(g)

Attachments

custom_gravity.zip (79.4 KB)

Depends on what you mean what surface.

Imagine a player is standing next to a wall. Is he supposed to stick to the wall or the ground or both?

Is any movement fine as long as the player touches any “surface” object? Which one is the object the player should be relative to (e.g. one leg on one platform, one leg on another - both platform moving into different directions.)

If player touches a wall, he gets on the wall. But I don’t think such a thing will appear, the question was about movement along a single cube or a single plane.

(e.g. one leg on one platform, one leg on another - both platform moving into different directions.)

There’s only one platform, the map-platform. It’s like a planet.

You gave an example of a mushroom which does not have a convex hull. Restricting towards a single (sur)face can be done. The conflicts when there is more than one face needs to be solved somehow. This is what my questions are heading to.

One option is to detect what face the player is nearest to. Then apply a force along the face normal.
As said, there can be several faces. With this concept you can get several contradictory forces.

Another option is to do nothing as long as the player touches a ground object/material. But if he does not, you perform some corrective operations (e.g. setting him back where he was before, or pushing to the nearest face).

Another (but simple to implement) option is to create “magnetic boots”. This means the player always falls towards his boots. This is not necessarily a direction with a surface.
Surely you can check the alignment of the face under the player. But this alignment might be extreme.

Another option is to define gravity rooms. This is similar to your “gravity script” idea. Rather than defining a single room with a gravity point, you define several rooms e.g. cubes, spheres with any gravity you like. e.g. one cube with a gravity towards one side, another room towards a center point. The single rooms influence the objects inside the limits only. Rooms can intersect, resulting in a combined gravity vector.

What is movement in Blender? Can I split surfaces of a mesh into points and then re-describe movement like changing position from one point to another?

2D movement on a 3D mesh. Sounds ideal: there’s no need in corrective operations, no places for glitches. Can it be?

What is movement in blender? Can I split surfaces of a mesh into points and then re-describe movement like changing position from one point to another?
2D movement on a 3D mesh. Sounds ideal: there’s no need in corrective operations, no places for glitches. Can it be?