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?
Realistic door, opening and closing on use
-
- Posts: 37
- Joined: Wed Jun 13, 2012 6:22 pm
- QuestOfDreams
- Site Admin
- Posts: 1520
- Joined: Sun Jul 03, 2005 11:12 pm
- Location: Austria
- Contact:
Re: Realistic door, opening and closing on use
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):
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;
}
}
}
}]
}
-
- Posts: 37
- Joined: Wed Jun 13, 2012 6:22 pm
Re: Realistic door, opening and closing on use
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?
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?
- QuestOfDreams
- Site Admin
- Posts: 1520
- Joined: Sun Jul 03, 2005 11:12 pm
- Location: Austria
- Contact:
Re: Realistic door, opening and closing on use
Have you set bRotating to true? IIRC this disables collision checking when the door starts to animate.
-
- Posts: 37
- Joined: Wed Jun 13, 2012 6:22 pm
Re: Realistic door, opening and closing on use
Not sure, I'll check.
-
- Posts: 37
- Joined: Wed Jun 13, 2012 6:22 pm
Re: Realistic door, opening and closing on use
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?
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?
- QuestOfDreams
- Site Admin
- Posts: 1520
- Joined: Sun Jul 03, 2005 11:12 pm
- Location: Austria
- Contact:
Re: Realistic door, opening and closing on use
Sorry, I can't think of a reason why this would happen.
-
- Posts: 37
- Joined: Wed Jun 13, 2012 6:22 pm
-
- Posts: 37
- Joined: Wed Jun 13, 2012 6:22 pm