Platypus strange random GO movement (SOLVED)

https://forum.defold.com/u/britzl: I’m getting some weird and random behaviour when manually moving a GO which has Platypus attached. I can’t pin down the exact circumstances but I have a vague feeling it may be only when the GO is touching a platform when moved and then not every time (so could be velocity or collision related). I have two instances in my game when I need to do this:

  1. The player died and I need to set the GO position back to a start or save point.
  2. The player enters a transporter pad and I need to set the GO position to the receiving pad.

The basic steps I’m taking are:

  1. Disable the collision object on the GO.
  2. Release input.
  3. Set the position with go.set_position(destination, “.”).
  4. Update the camera (I’m using the orthographic camera).
  5. Acquire Input.
  6. Enable the collision object on the GO.

Most of the time this works fine, but just once and a while the GO will get randomly deposited at an offset location with no logical reason why. I’ve tried falling into the teleporter, moving left or right into it and jumping on to it from various angles but there appears to be no repeatable pattern, which makes it a) frustrating and b) almost impossible to solve/debug.

The teleporter pad has a small box collision object and when I set it to platypus.DIR_DOWN the issue occurs, removing the collision object from the Groups list and just acting on a collision manually stops the random move problem. I’m guessing this is to do with collision separation and/or velocity.

So I have a workaround for the teleporter, but this still affects my player death and reset. Sometimes the player GO is set to a position thousands of pixels away from where it should be (which is a game breaking issue).

And so we finally get to my question! Is this a known issue or (hopefully) is there a better way/something I’m doing wrong of manually updating my player GO that will work better with Platypus? How do you do it?

Thanks in advance and keep up the good work, loving Defold and the community.

This is likely caused by the fact that Platypus will parent the game object to whatever it has ground contact with while keeping the world transform. If you move it to another position it will maintain it’s parent but probably also reparent in the wrong place when you get ground contact again.

You could try to remove the parent before moving it:

msg.post("player", "set_parent", { parent_id = nil, keep_world_transform = 1})
go.set_position("player", some_world_position)

Brilliant, thank you I’ll give it a go and let you know how I get on. If I re-enable the teleport pad in Platypus I can hit the issue fairly easily, it’s a lot more random with the player reset code.

Thanks for your help and quick response.

Yes, that worked perfectly. Thanks for your help and all your brilliant work.

1 Like