Shrek dissapears when attacking(Solved)

PROJECT FIVE NIGHTS AT RICARDOS ZIP
I TRY To IMPORT THE ZIP BUT I CANT WHEN I UPLOAD IT IT LOADS THEN DISSAPEARS, LIKE SHREK

--shrek.script
local function start(self)
	msg.post("#sprite", "play_animation", {id = hash("shrek_idle")} )
	go.set_scale(vmath.vector3(0.3, 0.3, 0.3))
	go.set_position(vmath.vector3(0, 80, 1))
	self.scale = true
end

local function attack(self)
	self.attacking = true
	msg.post("#sprite", "play_animation", {id = hash("shrek_active")} )
	self.attack_timer = delay.seconds(4, function(self)
		msg.post("/manager#manager", "shrek")
	end)
end

local function dwell(self)
	go.set_position(vmath.vector3(self.player_pos.x, self.player_pos.y, 50), "black")
	go.set_scale(vmath.vector3(7, 7, 7))
	for x = self.player_pos.x + 640, self.player_pos.x - 640, -10 do
		go.set_position(vmath.vector3(x, self.player_pos.y, 51))
		if x <=  self.player_pos.x - 640 then
			go.set_position(vmath.vector3(0, -5000, 0), "black")
			go.set_position(vmath.vector3(0, -5000, 0))
		end
	end
end

function init(self)
	msg.post(".", "acquire_input_focus")
	
	self.busy = false
	self.scale = false
	self.scale_count = 0.3
	self.mask = false
	self.mask_already = false
	self.attacking = false
end

function update(self, dt)
	if self.busy == false then
		self.chance = rnd.range(1, 1000)
		if self.chance > 1 then
			start(self)
			self.busy = true
		end
	end

	if self.scale == true then
		self.scale_count = self.scale_count + 0.025
		if self.scale_count < 0.8 then
			go.set_scale(vmath.vector3(self.scale_count, self.scale_count, self.scale_count))
		else
			go.set_scale(vmath.vector3(0.8, 0.8, 0.8))
			msg.post("#sprite", "play_animation", {id = hash("shrek_ready")} )
			self.scale_count = 0.3
			self.scale = false
			self.timer = delay.seconds(10, function(self)
				self.attack = true
				delay.cancel(self.timer)
			end)
		end
	end

	if self.attack == true then
		self.chance = rnd.range(1, 1000)
		if self.chance > 0 then
			attack(self)
			self.attack = false 
		end
	end

	if self.mask == true and self.attacking == true and self.mask_already == false then
		delay.cancel(self.attack_timer)
		msg.post("/screen#screen_notification", "shrek")
		self.mask_already = true
	end
end

function on_message(self, message_id, message, sender)
	if message_id == hash("pos") then
		self.player_pos = message.pos
		dwell(self)
	end
end

function on_input(self, action_id, action)
	if action_id == hash("mask") then
		if self.mask == true then
			self.mask = false
		elseif self.mask == false then
			self.mask = true
		end
	end
end

i called it cyberserked because i was suppose to draw out driods but i was too lazy so i used dead memes instead

so shrek (those who know fnaf it is exactly like toy freddy from fnaf2) is suppose to show up walking down the corridor, then he stands there for 10 seconds and turns into attack mode randomly, then u have 4 seconds to react and wear a mask, if u do not react shrek sends a message to the jumpscare controller to jumpscare u, if u react he will dwell which is just having darkness covering the screen while shrek moves from right to left. the he is gone

Tried to import zip in reply still doesnt work
:cowboy_hat_face:

Too big maybe? Make sure to exclude .internal and build folder when zipping your project.

1 Like

You posted under “Questions”, but I cannot find a single question in this post?

3 Likes

Oh wait I forgot to say the question
Shrek dissapears when the dwell function is called when the mask on

Note: player_pos is just the position of the camera.go

You’re setting z position to 50, which is way beyond the allowed range(-1 to 1). That is why it is not being rendered

1 Like

Way beyond the default near and far planes. It can be changed by sending a message to the render script.

2 Likes

Ok, so what’s the question?

1 Like

exactly :slight_smile:, though the usual range is most of the time fit for my purpose, and so I tend to stay away from stretching render projection (part of my renderphobia I suppose :wink: )

1 Like

oh i forgot to mention im using rendercam

and i set it to -100 to 100

i think its a scale problem u guys cant solve it if u dont have the project zip but thanks