Attaching a player to an object

Hello guys and giirls,

I’m trying to put together a proof of concept idea, which see’s our playable character movinga round in a 3d space, jumping from islands to islands, imagine these isdlands are like cubes, but when on the cubes the character should be able to move around these cubes on all faces/axis.

However, I’m not sure how to:

A: attach the player to these cubes

B: allow the character to move freely around these cubes

C: If the character was to shoot a bullet also, i’d liek the bullet to be confied to the cube, as if the cubes hav their own gravity

Any help would be greatly appreciated guys

This sounds a lot like a relative gravity kind of problem. There have been a few questions about this kind of thing (people looking for Mario Galaxy kind of systems) and, as I understand them, it boils down to something like this:

  1. From your character’s position, you find the closest piece of ground
  2. Raycast to that ground and use the normal to align the character/colliders etc properly
  3. apply ‘gravity’
  4. Do the same with anything that you want to follow the surface of your planetoid.

attach a player to cubes is just a matter of becoming a child of it. So it would be objectA.transform.parent = objectB

allowing the character to move around freely means that your character control has to control the characters local axis. keep the child as a child of the object. My game does something like this.