I was wondering if anyone would be able to help me with adding collision groups to my config table using Platypus. I have two scripts. One codes for player movement and animation and the other is a separate script with the platypus script in it. Both are attatched to the player game object and can be consolidated if anyone feels that would help. The reason that they are currently separate is that the line of code to initate the platypus instance currently breaks my player movement when added to the same script.
I have looked at both examples and the documentation but I am still confused as I am an inexperienced programmer who hasn’t been using Defold for very long.
Here’s my Platypus script below. I only want Platypus for implementing singular jumps which is why a lot of things are marked as false.
local platypus = require "platypus.platypus"
local config = {
collisions = {
separation = platypus.SEPARATION_RAYS,
groups = {
[hash("ground")] = platypus.DIR_ALL,
[hash("logs")] = platypus.DIR_ALL,
},
left = 22, right = 22, top = 35, bottom = 43, offset = vmath.vector3(0, 0, 0)
},
gravity = -800,
max_velocity = 300,
allow_double_jump = false,
allow_wall_jump = false,
allow_wall_slide = false,
wall_slide_gravity = nil,
debug = true,
}
function init(self)
self.platypus = platypus.create(config)
end
function update(self, dt)
self.platypus.update(dt)
end
function on_message(self, message_id, message, sender)
self.platypus.on_message(message_id, message)
end
My current objects are the player, the ground and a log. All have collision objects attatched to them but only the player has a Platypus instance. I have changed the boundaries so that it fits the player. I assume that I will eventually have to create Platypus instances for all of the objects that require collision but I am unsure how to link them all together so that they interact correctly. If someone with more experience with Platypus would be help/explain to me how to do it then I would greatly appreciate it as this is for a school project.
If more information is needed then I’m happy to provide it!
I don’t really have enough time to sort it out right now but I zipped up the file and the forum is telling me that it’s too large to upload. I will try and figure it out later. Maybe I can upload it to GitHub or something? Thanks for taking a look for me.
As I’ve had to leave the house and have already created the repository, I shall do it using GitHub. What is your name on there? I can try to add you as a collaborator through my phone.
I’m currently a bit confused because everything is appearing on GitHub Desktop but although I have clicked Repository > Push it’s not actually appearing on GitHub. Now that I am back at my computer, I will try zipping the file again.
If you have trouble seeing things (e.g. the background), review z-positions. Make sure to keep things within the range -1 to 1. You don’t need to put the background at -1, it’s enough that it is the lowest z value (e.g. -0.1 or whatever). Remember z values are cumulative, e.g. if a gameobject is z -0.1 and a sprite attached to it is -0.2, then actually the sprite will be rendered at -0.3.
Thank you so much for taking a look! I am incredibly grateful that you’ve managed to get the character to jump. I’ve been trying to get it to work for a week haha.
Once I’ve escaped the airport, I shall edit my code with your suggestions. Thank you for providing clear and concise instructions and pictures too. That is incredibly helpful and I appreciate you taking the time to have a look for me! Thank you ever so much once again!
Do you know if there is a way to keep the player speed consistent when jumping/falling? Right now, the player speeds up when jumping or falling off an object.
We are getting a bit deep into platypus here which I haven’t used before, I suggest you poke around a bit more yourself or someone else more experienced might chime in!
That’s okay! Thanks anyway! I had a little fiddle around with some of the values including upping my player speed to match the jump velocity but couldn’t find anything that worked. I shall have a more deeper look but if it stays as it is, for a school project it won’t matter too much. Thank you for all your help!