Camera staying in place

Now the camera, no matter where the game object is will show the same spot. Can I get some help?
Here’s the script :

function init(self)
	msg.post("camera#Camera", “acquire_camera_focus”)
	msg.post(".", "acquire_import_focus")
	msg.post(".", "menu")
	self.play = 0
	-- 0 = none; 1 = rules; 2 = win; 3 = lose; 4 = game; 5 = credits; 6 = menu
	-- 7 = dates
	self.timer = 0
	go.set_position(vmath.vector3(-684, -260, 0))
end

function update(self, dt)
	if (self.play == 1) then
		go.set_position(vmath.vector3(1244, -200, 0))
		local timer = self.timer
		self.timer = timer + 1
		if (self.timer == 600) then
			self.timer = 0
			self.play = 4
			msg.post("enemy#enemy", "play")
			msg.post("player#player", "play")
		end
	end
	if (self.play == 2) then
		go.set_position(vmath.vector3(684, 260, 0))
		local timer = self.timer
		self.timer = timer + 1
		if (self.timer == 600) then
			self.timer = 0
			self.play = 5
		end
	end
	if (self.play == 3) then
		go.set_position(vmath.vector3(684, -260, 0))
		local timer = self.timer
		self.timer = timer + 1
		if (self.timer == 600) then
			self.timer = 0
			self.play = 5
		end
	end
	if (self.play == 4) then
		local vec = go.set_position(go.get_position("player"))
		local x = vec.x
		local y = vec.y
		local z = vec.z
		if (vec.x > 119) then
			x = 120
		end
		if (vec.x < -119) then
			x = -120
		end
		if (vec.y > 259) then
			y = 260
		end
		if (vec.y < -259) then
			y = -260
		end
		go.set_position(vmath.vector3(x, y, z))
	end
	if (self.play == 5) then
		go.set_position(vmath.vector3(1244, 200, 0))
		local timer = self.timer
		self.timer = timer + 1
		if (self.timer == 600) then
			self.timer = 0
			self.play = 6
		end
	end
	if (self.play == 6) then
		go.set_position(vmath.vector3(-684, -260, 0))
	end
	if (self.play == 7) then
		go.set_position(vmath.vector3(-684, 260, 0))
	end
end

function on_message(self, message_id, message, sender)
	if (message.id == hash("play")) then
		self.play = 1
	end
	if (message.id == hash("dates")) then
		self.play = 7
	end
	if (message.id == hash("win")) then
		self.play = 2
	end
	if (message.id == hash("lose")) then
		self.play = 3
	end
	if (message.id == hash("menu")) then
		self.play = 6
	end
end

One possible error is that you send the first message to “camera#Camera”. This should be “/camera#Camera”, if the game object to which you send the message is called “camera”.

Have you followed all the steps in the manual and added the objects properly?

That was not the error, I checked. I also moved all the files around to double check if I did add objects properly and yet camera doesn’t seem to move from that position.

2018-06-07%20(1)

I’ve seriously tried everything like changing the camera name in the script to acquire camera focus, to moving it around in the collection and I even started looking up other tutorials and yet nothing, simply nothing changed about the camera’s position on the screen.

Let’s not discuss the same problem in two threads. I’ve posted what I believe is a clear answer to your question here: Camera Trouble (SOLVED)

2 Likes