Particles not showing after I jump, even after calling particlefx?

This is where I am calling the function:
issueJumpCode

This is the player outline, where the Jump has been added:
issuePlayerOutline

Properties of particle:

Is there something else I am missing? Thanks for any input!

I think you need to use the id of the emitter. In your case #emitter.

As in: particlefx.play("#emitter") ? Because I tried that but no luck

Sorry, my bad. I’m fairly new to the editor myself :slight_smile:. Checked my project and you were right. #jump should work. I have the same set up. Have you tried playing the particlefx in the editor to see what it would look like?

Yeah, I can see what they are supposed to look like at least :frowning:

Looks like there’s an error somewhere in your player script. If it’s in the jump code (or any code before it), that would stop the particles from playing. Could you post what’s around line 153?

Yeah sure, I don’t think it could be causing this issue though, but then again what do I know

error

If you see an error in the console then immediately stop what you are doing and fix the error. This is a good recommendation in any kind of software development and I strongly recommend it here too.

To test the particle effect you could perhaps add the code to play it to the init() function and change your play mode from Once to looping (as a test).

1 Like

You should also copy and paste text using the lua code gates, this will make it in much easier for us to help you. Looks like this:

your code goes here 

we can see in the console that you have an error in your script. This means your code will stop running. Solve this issue first, otherwise we don’t know what (else) might be wrong.

You should also try running the particle FX in the first line if the init function, and learn how to use print to see where errors come from (check the console whilst the game is running)

print(distance)
print("this is line 532")
2 Likes

I have included the code where the error comes from, as I have no idea how to fix it. Any help is greatly appreciated

lines 160 to 197:

local function handle_obstacle_contact(self, normal, distance)
if distance > 0 then
	-- First, project the accumulated correction onto
	-- the penetration vector
	local proj = vmath.project(self.correction, normal * 
	distance)
	if proj < 1 then
		-- Only care for projections that does not overshoot.
		local comp = (distance - distance * proj) * normal
		-- Apply compensation
		go.set_position(go.get_position() + comp)
		-- Accumulate correction done
		self.correction = self.correction + comp
	end
end
-- collided with a wall
-- stop horizontal movement
if math.abs(normal.x) > 0.7 then
	self.wall_contact = true
	self.velocity.x = 0
end
-- collided with the ground
-- stop vertical movement
if normal.y > 0.7 then
	if not self.previous_ground_contact then
		-- reset any "squish" that may have been applied
		go.set("visuals", "scale", 1)
		self.double_jump = false
	end
	self.ground_contact = true
	self.velocity.y = 0
end
-- collided with the ceiling
-- stop vertical movement
if normal.y < -0.7 then
	self.velocity.y = 0
end

end

lines 201 to 214 :

function on_message(self, message_id, message, sender)
if message.group == GROUND then
	handle_obstacle_contact(self, message.normal, message.distance)
elseif message.group == MOVPLAT then
	-- reparent so that the player moves with the platform
	msg.post(".", "set_parent", { parent_id = message.other_id })
	handle_obstacle_contact(self, message.normal, message.distance)
elseif message.group == RESPAWMN or message.group == ENEMY then
	-- remove parent to ensure we can move when respawning
	msg.post(".", "set_parent", { parent_id = nil })
	print(self.spawn_position)
	go.set_position(self.spawn_position)
end

end

Can you add print(normal, distance) like this:

local function handle_obstacle_contact(self, normal, distance)
print (normal, distance)
if distance > 0 then

And tell us what you get in the console? Thanks.
Please also share your whole script, indicating which line is number 153. Thanks

Console output:

issueConsole

I have just attached the script file as a file so you can see it easily:
player.script (8.8 KB)

Thanks again

You’re calling a function with two nil variables. Right before “ERROR:SCRIPT:” in your console, you can see it says “nil nil”. This is the result of the “print(normal, distance)” line of code. That means that when you try to do

if distance > 0 then

you can’t compare distance to 0, because it’s nil.

please try adding pprint(message) as indicated below. (pprint, with two Ps, is used to print a table). Copy and paste the table from the console.

function on_message(self, message_id, message, sender)
	pprint(message)
	if message.group == GROUND then

Hi there, isn’t the message_id missing in your code, so there is no message received? Try this:

function on_message(self, message_id, message, sender)
	if message_id == hash("contact_point_response") then
		if message.group == GROUND then
			handle_obstacle_contact(self, message.normal, message.distance)
		elseif message.group == MOVPLAT then
			-- reparent so that the player moves with the platform
			msg.post(".", "set_parent", { parent_id = message.other_id })
			handle_obstacle_contact(self, message.normal, message.distance)
		elseif message.group == RESPAWMN or message.group == ENEMY then
			-- remove parent to ensure we can move when respawning
			msg.post(".", "set_parent", { parent_id = nil })
			print(self.spawn_position)
			go.set_position(self.spawn_position)
		end
	end
end
2 Likes

Well, there you have it.
On line 161, you print out the value of distance, and its value is nil. On line 162, you try to use the value (nil`) to do a comparison, which won’t work.

Assuming that you don’t want the variable distance to be nil, you should debug why it is nil.
E.g. did you intend to use self.nil or something.

Hi, thanks, this worked perfectly as fixing the error, however the particles are still not showing :frowning:

1 Like

Ah I see, I just tried another person’s method and it fixed the error anyway, but still no particlefx showing on screen

:grin: The other person, aka me, shouldn’t have bumped so quickly, I guess - I think, the others wanted to guide you towards finding the cause of the error yourself. Sorry guys! :flushed:

To be fair, I was so focused on the distance > 0 that I don’ think I would have even realised I was missing the message_id, so thanks :sweat_smile:

1 Like