How to make a player ride on top of a box/platform?
Hello! I'm making a game where one of the way for the player to move is for the player to jump on top of a block. In this game magnetic charges can be shot at blocks and walls, so the way you would move is having standing on top of the block and shooting the magnetic charges in a way so that the block would be attracted to a wall. Anyways, I'm achieving this magnetic effect with move towards and it works great, but I'm having a problem with the above said way of movement. The problem is that because the player has a mass of more than 0 it weighs down the block and it can only move horizontally and I need to move both horizontally and vertically. Ok, great, I set the mass to zero, but now since its technically not colliding with the block it goes to the jumping animation and falls off the block. I've tried ways of constraining the x and y of the block and making the player's x and y equal them with the player having a mass of zero but that doesn't work either. This was probably confusing, so let me sum this up quickly.
I need to have a player travel on horizontally and vertically moving blocks without falling off.
These blocks are moving with a move towards behavior.
The player's mass is weighing down the vertical movement.
Making the mass 0 creates more problems.
Thanks!
I need to have a player travel on horizontally and vertically moving blocks without falling off.
These blocks are moving with a move towards behavior.
The player's mass is weighing down the vertical movement.
Making the mass 0 creates more problems.
Thanks!
Answers
First of all, is having 0 mass causing problems on or off the blocks, or just while on them? If it is causing problems if they are only off the blocks, then try this...
Create a boolean att called game.blocks (or whatever)
Rule: When character overlaps or collides with block, change att game.blocks to true
When att game.blocks = true, change mass to 0
Otherwise, change mass to whatever it was before.
If this doesn't work I would need a little bit more explaining on the problem with having no mass.
Hope this helps,
Jack McGraw
Physics attributes cannot be changed in game.
Really? That's a bummer... I had no idea.
Sorry @pxlpfct I guess my idea wouldn't work at all. If I can think of something else later today, I'll post another comment.
Jack McGraw
In other words:
boolean_horizontal_gravity is "on" with all the normal physics.
man "shoots" grav-gun, sets boolean_horizontal_gravity to "off" with modified physics.
I wish I knew the physics engine a bit better. I'm new to the game, but it seems to me that you have two different cases you are trying to marry into one. If you try to separate your cases, you might find a solution.