Configuring Collision Groups in Platypus [SOLVED]

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!

Can you zip up the project and share 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 it won’t let me upload the zip fil, I have created a repository on GitHub. Is that good for you?

Yeah that would be fine. You can normally delete the build folder as well to reduce file size.

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.

@Alex_8BitSkull

8bitskull

Thank you. I’ll get on it now!

Afraid you didn’t push your project to the git repo :slight_smile:

Oh. My bad. I’ll try to fix that now!

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.

Here:

NEAZipped1.zip (115.1 KB)

Let me know if there any problems. Sorry for all the hassle.

Your player collision object is “Dynamic”. This will not work, read more about why here: Collision objects in Defold

Change this value to Kinematic:

You have not applied groups and masks to your collision objects. Review the documentation here: Collision groups in Defold

This is how I set up the player:

This is how I set up the ground:

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.

End result:

4 Likes

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! :smiley:

1 Like

It works! Thank you so much for all of your help!

1 Like

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!

1 Like

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!

1 Like

The best way to get help from me is to open an issue on GitHub.

Okay! Thanks for your reply. I currently have a headache but I will look into doing that later :smiley: