Jump to content

[4.6] Sliding Door Script Start Open (With Fix)


Recommended Posts

Simple script issue where the stock Sliding Door script no longer starts open when told to do so out of the box. This is my Start function fix. If you think of anything better, let me know.

function Script:Start()
	self.entity:SetGravityMode(false)
	if self.entity:GetMass()==0 then
		Debug:Error("Entity mass must be greater than 0.")
	end

	self.sound={}

	if self.opensoundfile~="" then self.sound.open = Sound:Load(self.opensoundfile) end
	if self.loopsoundfile~="" then self.sound.loop = Sound:Load(self.loopsoundfile) end
	if self.closesoundfile~="" then self.sound.close = Sound:Load(self.closesoundfile) end
	
	if self.sound.loop~=nil then
		self.loopsource = Source:Create()
		self.loopsource:SetSound(self.sound.loop)
		self.loopsource:SetLoopMode(true)
		self.loopsource:SetRange(50)
	end

	if self.manualactivation==false then self.Use=nil end

	self.opentime=0
	
	--Create a motorized slider joint
	local position=self.entity:GetPosition(true)
	local pin=self.distance:Normalize()
	self.joint=Joint:Slider(position.x,position.y,position.z,pin.x,pin.y,pin.z,self.entity,nil)
	self.openangle=self.distance:Length()
	self.closedangle=0

	if self.openstate then
		self.entity:SetPosition(position+self.distance)
		self.joint:SetAngle(self.openangle)
	end

	self.joint:EnableMotor()
	self.joint:SetMotorSpeed(self.movespeed)
end

 

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

For what it's worth.  We have begun some further work on Forth Project (in game projects).  We found some oddities with physics where platforms were floating up that previously were stationary.  It isn't code I wrote, haven't looked closely at it, and I'm focusing on some modelling at the minute so I don't have any info on what the cause is.  I am sticking with 4.5 for this project.

I am just reporting it to inform that there do seem to be some differences physics between 4.5 and 4.6.  If I get to investigating that I'll update or if there are changes in 4.6 we can probably check against our know problem area in Forth as an extra test bed.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...