Page 1 of 1

Realistic door, opening and closing on use

Posted: Mon Jun 25, 2012 9:36 pm
by Agentbromsnor
I've been experimenting with the door-entity in RF. I think I've got it all figured out with the animating and the settings, but for my game I would like to be able to open and close doors when used. So, once the player opens the door, the door has to stay open untill the player closes it again.

What would be the best way to achieve this?

Re: Realistic door, opening and closing on use

Posted: Mon Jun 25, 2012 11:25 pm
by QuestOfDreams
The best way to do this is to use a LevelController entity + script.
Use the DoorDistance method to check if the player is in the range to open/close the door. If true use self.key_pressed to check if the Use key is pressed. Then use SetDoorTargetTime to open/close the door. Something like this (not tested):

Code: Select all

{
	USERANGE [100]
	USEKEY [22]
	DDIST  [0.0]    // Distance to door01
	DOPENTIME [2.5] // Open door time
	OPENING [false]

	Start[()
	{
		DDIST = DoorDistance("door01", "Player", true);

		if(DDIST < USERANGE)
		{
			if(self.key_pressed = USEKEY)
			{
				if(OPENING)
				{
					// close door
					SetDoorTargetTime("door01", 0.0);
					OPENING = false;
				}
				else
				{
					// open door
					SetDoorTargetTime("door01", DOPENTIME);
					OPENING = true;
				}
			}
		}
	}]
}

Re: Realistic door, opening and closing on use

Posted: Tue Jun 26, 2012 1:08 am
by Agentbromsnor
Thanks for getting me on the right track! I'm gonna give it a go.

Also, I noticed that a regular animated door can pass through the player when it swings open or closed. Is there a way to make the animated door 'solid', so to say?

Re: Realistic door, opening and closing on use

Posted: Tue Jun 26, 2012 10:32 pm
by QuestOfDreams
Have you set bRotating to true? IIRC this disables collision checking when the door starts to animate.

Re: Realistic door, opening and closing on use

Posted: Tue Jun 26, 2012 11:38 pm
by Agentbromsnor
Not sure, I'll check. :)

Re: Realistic door, opening and closing on use

Posted: Wed Jun 27, 2012 11:37 pm
by Agentbromsnor
This is kinda unrelated, but its just something that popped up.

I got an new version of a level send by EvilDraggie, and suddenly in-game the bumpmaps looks really pixelised and ugly. I'm 100% they didn't look like this before. Is there a reason for this? :?

Re: Realistic door, opening and closing on use

Posted: Thu Jun 28, 2012 7:33 pm
by QuestOfDreams
Sorry, I can't think of a reason why this would happen.

Re: Realistic door, opening and closing on use

Posted: Thu Jun 28, 2012 9:14 pm
by Agentbromsnor
Hmm... Let me show you a screenshot to clarify what it looks like:

Image

Re: Realistic door, opening and closing on use

Posted: Sun Jul 01, 2012 8:04 pm
by Agentbromsnor
Agentbromsnor wrote:Hmm... Let me show you a screenshot to clarify what it looks like:

Image
Never mind, this issue has been resolved! I was just being retarded, the texture pack was updated and I wasn't aware of it. :P