Jump to content

Have a small problem with the Swinging door script


bansama
 Share

Recommended Posts

As a follow on from this topic: http://www.leadwerks.com/werkspace/topic/10226-where-can-i-find-this-example-map/

 

I now have sliding doors set up. These I can now make without a problem. But in doing so I have noticed something which I think is caused by something in the sliding door script itself, but I have no idea what exactly.

 

The problem is that once a door has been opened (I'm using the manual activate set to true, with closing delay set to 0) when you close it, it always ends up a tiny degree off from its starting point. It's as if the script is ending before the very last degree of movement so it cannot come to rest at its original position.

 

To be honest, I doubt it's something most would notice unless specifically looking for it, but it is a little annoying nonetheless.

 

Any ideas on what's going on and how it could be fixed?

Link to comment
Share on other sites

I think it's just a function of the physics joints. Once they are pretty close to resting, the object falls asleep.

 

Also, make sure your doors and surrounding walls are both using the "Scene" collision type, so they don't collide and there is no friction on the joint.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

@Josh Yeah, I've checked and both the door and the door frame prefab I made have their collision type set to Scene. At first I thought it might be because I'm using a prefab, but I get the same thing when I don't too.

 

I think I'll just redesign the door frame so this is less noticeable for now.

 

Thanks.

Link to comment
Share on other sites

I ended up looking into this more and seem to have found a solution that works well enough.

 

First I added this at the start of the SwiningDoor script. The default value is what has worked best for me so far.

 

Script.closeoffset=1.3--float "Close offset"

 

And then making the very simple change of:

 

self.joint:SetAngle(self.closedangle)

to

self.joint:SetAngle(self.closedangle-self.closeoffset)

 

As shown below:

 

function Script:Close()--in
if self.enabled then
if self.openstate then
self.openstate=false
if self.loopsource then
self.loopsource:Release()
self.loopsource=nil
end
if self.closesound then
self.entity:EmitSound(self.closesound)
end
self.joint:SetAngle(self.closedangle-self.closeoffset)
self.component:CallOutputs("Close")
end
end
end

Link to comment
Share on other sites

  • 2 months later...

I cant seem to get this script to do anything to any door I have! The door is set to scene, the frame is set to scene and making any changes to any of the variables does absolutely nothing for me to make this door open. Any suggestions?

 

The function seems to be working BUT the actual door does not swing open. The door image/texture stays put but the physics of the door function so it appears as though you are walking through the door.

Asus sabertooth 990FX, AMD FX 9590 , Windows 7 Home Premium 64 Bit, 4 HDD's Western Digital Caviar Black set in Raid 0, 16 GB Crucial Ballistix Elite, Asus Radeon R9 270 X 4GB, Corsair CM750M,

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...