Open a Door ( And not close it again)

Hey, i’ve made another post/thread about a door opening thing…

I have an First person view game with movement, and camera, flashlight, and stuff.

I added a door, which i’ve been trying to make so you can open and close for a pretty long time :confused:

On my prev thread, i asked about some help with opening and CLOSING a door, but i’ve decided, that i just wanna be able to open it, and not close it again.

I have a door with the property : door

and a player with the property: player

Now, also i only wanna be able to open it when im near it, not standing across the room and open it… :confused:

Thats been the hard part…and im kinda new to blender ;(

Well, if you have any ideas, please post them :slight_smile:

(PS. i havent found any tutorial on this)

Thanks in advance :slight_smile:

Try using a collision and keyboard sensors on the door.

Collision with property player and Keyboard key pressed = door open


DoorOpen.blend (79.5 KB)

Wouldn’t you want it so that if you clicked the door it opens, and when you clicked it again it closes?

Anyways, there’s a ton a ways you can achieve this, the easiest being with an IPO and, of course, python. I’ll make you a quick example.

Basically, we need to grab the objects that are near the player object, and the easiest way to do that is with python. I won’t explain the code (because you just said you’re a beginner) so I suggest you look up some python tutorials because making an FPS is freakin’ impossible without the flexibility of coding.

So here’s the example,
WASD to move.

door_example.blend (443 KB)

I’ve made it very simple for you, so you can use it with no python skills at all.

Make sure the player object has two properties, one called “doors” and the other called “door_max_dist”. In “doors” (this is a string) you type in the property that all your doors will have (this is so the player knows what’s a door). In the “door_max_dist” you type in the distance you want to be able to sense doors from (leave this as a float or integer). To run the script, connect an always sensor (with true pulse) to a python controller in module mode, and type in “door.main”

Then just make sure to copy the setup on from door object to door object; the properties and the logic bricks. You only need to setup the player once and the length of the door animation doesn’t matter.

Try it out!

The above post is good too, but I still suggest my method because it’s way faster to do once you have the initial setup done, and you don’t have to touch the door.

Oh, and here’s another example of the door closing when you’re too far away… I thought that’d be useful too.
door_example2.blend (446 KB)

you can also use a near sensor with property “player” , put a distance about 3.0

on the obj player not forget to put the flag on the “actor” (physic panel) otherwise near sensor not work

so, on the door logic brick :

NEAR[“player”] -> AND-> action(play)

PS:maybe do an action long, 0/100 open … 500/600 close

That’s also a good idea Marco if you’re going with the non-logic brick method but near sensors are expensive to use :confused: Not sure how bad the FPS would be with 10+ doors. It’s totally fine though if you’re only going to have a few doors per scene; really nice alternative.

as performance , is true .
in a FPS (player oriented) you can centralize all , and this make all more fast.(if you have many doors)

anyway , i just experiment the unknow word of bricks (i take a bit of time to make it :slight_smile: )

I have a bit of CPU to spare :slight_smile:

I gave him a great collision based door, he just needs some time digesting things…

you can open a door with logic and motions, python and motions, logic and animation keys and a action actuator, or with python initiating an action,

I like logic :slight_smile:

I would work on using logic to do motions yourself :slight_smile:

and then python,
Logic= systems that do not need to know anything that is not pre-defined
python = great at everything
logic+python = probably best…


DoorLogic.blend (481 KB)

My system… is triggered by spawning an object “PlayerGrab” and it colliding with the switch, but initially pressing space will trigger it, just delete the space part… if you need step by step or get stuck, just do crtl+print screenand then open paint etc, do ctrl+V to paste in, and point an arrow to your issue, then send it to us,

I can take you through some stuff step by step :slight_smile: