Page 1 of 1

Doors

Posted: 2017-03-02, 12:20
by arfur9
The game I hoping to do is more an adventure game not a shooter, it will be a first person view
The game will be in a regular house with opening swing doors like any home... so on that note, what is the best way to do this?
An animated door or rotate the door by script?
Would it be possible to trigger the door by a mouse/cursor click on the door handle?
Also locked doors requiring a key?

Re: Doors

Posted: 2017-03-02, 13:07
by Carsten
All doable!
Have you seen http://forum.cafu.de/viewtopic.php?p=6915#p6915?
I may rewrite this in greater detail if required.

An adventure is a great idea, I'm very much looking forward to it!

Re: Doors

Posted: 2017-03-02, 15:20
by arfur9
Yes I did see it, I'm not very good with lua

I'll persevere a while longer, I'll create a door in the context and I'll see if I can get it working

Can the door be a model? I don't appear to be able to get a model to move and I've noticed that the lifts etc examples are primitives.

Re: Doors

Posted: 2017-03-02, 15:38
by Carsten
Yes, doors can be models, just add a component as required.
Let me know if you need help.

Re: Doors

Posted: 2017-03-02, 17:59
by arfur9
I will don't worry :)

Re: Doors

Posted: 2017-03-03, 14:49
by arfur9
Ok I know have a door triggering but not a swing motion, looking at the MoverBinary this hasn't been added yet?
I thought it might be able to use something like

Code: Select all

SetRotation(e,0,90,0)
I'm not to bothered if the door swings instantly open from 0 to 90 degrees right now, I can try to make it better later :)

Re: Doors

Posted: 2017-03-04, 12:02
by Carsten
I've added an issue for this, please see https://bitbucket.org/cafu/cafu/issues/ ... nentmovert for details.

I'll look into it, but if you want a quick solution, just move the doors out of the way linearly.

Re: Doors

Posted: 2017-03-04, 12:17
by arfur9
I guess the "easier" solution would be to animate the door?
Have a range of 100 frames, frames 0 to 49 open the door, frame 50 to 100 close it

Can we call a particular frame range?

Re: Doors

Posted: 2017-03-04, 18:57
by Carsten
In theory (I'm quite sure but have not tried), this can be done, especially if you can make it so that the door has two animation sequences: opening and closing.

The better solution however is (fixing #156 and) using the MoverBinary.

Re: Doors

Posted: 2017-03-04, 19:19
by arfur9
The MoverBinary is a lot more use to me as I'm a Sketchup user, we can't export animation
I'm trying an animated door with Blender :)

But even the Blender game engine uses a script rather than animation

Re: Doors

Posted: 2017-03-05, 11:18
by arfur9
it was really easy to get the door to open

Code: Select all

local Trigger = ...

function Trigger:OnTrigger(Other)
    -- Don't re-enter this code while we're still busy.
    if self.IsBusy then return end
    self.IsBusy = true

    local Map   = world:GetRootEntity()
    local AniRun= Map.doorani:GetComponent("Model")
     AniRun:set("Animation",1)
    Console.Print("Door close triggered!\n")

    -- Wait 2.1 secs, then become available again for the next trigger action.
    coroutine.yield(2.1)
    self.IsBusy = false
end
I guess now I need to figure out either a mouse/cursor click action or maybe keyboard input? ie a message to click a key to open or close

Re: Doors

Posted: 2017-03-06, 10:24
by Carsten
arfur9 wrote:I guess now I need to figure out either a mouse/cursor click action or maybe keyboard input? ie a message to click a key to open or close
At this time, the easiest solution by far is to use a trigger volume, possibly a very thin one so that the player must be very close to the door in order to open it (or have his key inventory checked).

Next easiest solution is using a GUI panel.

If you want something like a "Use" key, I'd have to look into it. Key mapping is not something that works easily or well yet.

Re: Doors

Posted: 2017-03-06, 12:03
by arfur9
Right now I have a trigger close to the door with a isopen condition, most doors once open can stay open, it would be exterior doors that need to close

Have you had any luck with the GUI problem?

Re: Doors

Posted: 2017-03-07, 11:55
by Carsten
I was looking into the rotating movers issue #156 first, because that is the slightly simpler problem and I was not aware if there are any priorities.
Regarding #157, don't expect results too quickly: this is a complicated problem that requires careful planning.

Re: Doors

Posted: 2017-03-07, 14:37
by arfur9
I'm just interested, the GUI is a nice feature :)