Tutorial - Runner (SOLVED)

Maybe that’s a strange question. I analyze the runner game. I added a simple speed shift.
Why if score is greater than 100, one platform instance does not change the speed?
I don’t understand something or is it an engine error?

Even if I send a message to all the controllers, the effect is the same

msg.post("ground/controller#script", "set_speed", { speed = self.speed })
msg.post("controller#platform_factory", "set_speed", { speed = self.speed })
msg.post("controller#platform_long_factory", "set_speed", { speed = self.speed })

Not sure really. I don’t remember the details of that tutorial. It’s not a bug in the engine though, that I can guarantee.

OK, thank you, I’ll wait, maybe someone will show me a problem that I don’t see yet

I suggest that you try to figure out what is wrong. Some suggestions:

  • Check the console. Do you see any errors?
  • Add a print(message_id) at the top of the on_message function in the receiving scripts. Do they receive the message you sent?
2 Likes

I think I know what the problem is. I need to send a speed change message to the script which is the object prototype. How to do it ?

image

I solved.

For dynamic objects we have to use:
msg.post(msg.url(nil, ID, “script”), “set_speed”, { speed = self.speed })

	if self.score > 100 then
		self.speed=6
		msg.post("ground/controller#script", "set_speed", { speed = self.speed })

		for i, p in ipairs(self.spawns) do
			msg.post(msg.url(nil, p, "script"), "set_speed", { speed = self.speed })
		end
	end
1 Like