Announcement

Collapse
No announcement yet.

Need help getting animated door from blender to UDK

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    To my knowledge the code below is related to here: https://en.wikipedia.org/wiki/Angels...t:_Planetstorm

    This may be helpful to you because it includes the possibility for animation, hence it may help you out with your doorhandle.
    defaultproperties are sparce but should be easy enough to work out.

    Code:
    class AFFSkeletalDoor extends SkeletalMeshActor
        hidecategories(Navigation)
        placeable;
    enum SkeletalDoorState
    {
        DoorState_Open,
        DoorState_Opening,
        DoorState_Closed,
        DoorState_Closing,
        DoorState_Destroyed,
        DoorState_None,
    };
    
    var() float Health;
    var bool bReverseOpenToClose;
    var() SoundCue ClosedSound;
    var() SoundCue OpenedSound;
    var() SoundCue CloseSound;
    var() SoundCue OpenSound;
    var() /* 00000008 */ AudioComponent SoundComponent;
    var() float DoorClosingTime;
    var() float DoorOpeningTime;
    var SkeletalDoorState NextDoorState;
    var SkeletalDoorState LastDoorState;
    var() SkeletalDoorState DoorState;
    var() EPhysics DestroyPhysics;
    var() Name DestroyAnimation;
    var() Name CloseAnimation;
    var() Name OpenAnimation;
    
    simulated function SetDoorState(SkeletalDoorState NewDoorState)
    {
        LastDoorState = DoorState;
        DoorState = NewDoorState;
        bForceNetUpdate = true;
    }
    
    simulated event TakeDamage(int DamageAmount, Controller EventInstigator, Vector HitLocation, Vector Momentum, class<DamageType> DamageType, optional TraceHitInfo HitInfo, optional Actor DamageCauser)
    {
        TakeDamage(DamageAmount, EventInstigator, HitLocation, Momentum, DamageType, HitInfo, DamageCauser);
        if (Health > 0)
        {
            Health -= DamageAmount;
            if (Health <= 0)
            {
                DestroyDoor();
            }
        }
    }
    
    simulated function PostBeginPlay()
    {
        PostBeginPlay();
        if (DoorState == 0)
        {
            OpenDoor(true);
        }
        else
        {
            if (DoorState == 1)
            {
                OpenDoor(true);
            }
            else
            {
                if (DoorState == 2)
                {
                    CloseDoor(true);
                }
                else
                {
                    if (DoorState == 3)
                    {
                        CloseDoor(true);
                    }
                    else
                    {
                        if (DoorState == 4)
                        {
                            DestroyDoor(true);
                        }
                    }
                }
            }
        }
    }
    
    simulated function ShowDoorState()
    {
        if (DoorState == 1 || DoorState == 0 && LastDoorState != 0 && LastDoorState != 1)
        {
            OpenDoor(true);
        }
        else
        {
            if (DoorState == 3 || DoorState == 2 && LastDoorState != 2 && LastDoorState != 3)
            {
                CloseDoor(true);
            }
            else
            {
                if (DoorState == 4)
                {
                    DestroyDoor(true);
                }
            }
        }
    }
    
    simulated function ReplicatedEvent(Name VarName)
    {
        if (VarName == 'DoorState')
        {
            ShowDoorState();
            LastDoorState = DoorState;
        }
        else
        {
            ReplicatedEvent(VarName);
        }
    }
    
    simulated function StartDoorState(SkeletalDoorState NewDoorState, Name DoorAnimation, optional float StateDuration = 0)
    {
        SetDoorState(NewDoorState);
        SkeletalMeshComponent.PlayAnim(DoorAnimation, StateDuration, false);
        if (StateDuration > 0)
        {
            SetTimer(StateDuration, false, 'FinishDoorState');
        }
        else
        {
            FinishDoorState();
        }
    }
    
    simulated function ToggleDoor()
    {
        if (DoorState == 0)
        {
            CloseDoor();
        }
        else
        {
            if (DoorState == 2)
            {
                OpenDoor();
            }
        }
    }
    
    simulated function DestroyDoor(optional bool bForce = false)
    {
        if (DoorState != 4 || bForce)
        {
            SetDoorState(4);
            if (DestroyAnimation != 'None')
            {
                SkeletalMeshComponent.PlayAnim(DestroyAnimation, 0, false);
            }
            if (DestroyPhysics == 10 || DestroyPhysics == 2)
            {
                SkeletalMeshComponent.SetHasPhysicsAssetInstance(true);
                SkeletalMeshComponent.ForceSkelUpdate();
                SetPhysics(DestroyPhysics);
                SkeletalMeshComponent.PhysicsAssetInstance.SetAllBodiesFixed(false);
                SkeletalMeshComponent.bUpdateKinematicBonesFromAnimation = false;
                SkeletalMeshComponent.WakeRigidBody();
            }
            else
            {
                SetPhysics(DestroyPhysics);
            }
        }
    }
    
    simulated function CloseDoor(optional bool bForce = false)
    {
        if (DoorState == 0 || bForce)
        {
            StartDoorState(3, CloseAnimation, DoorClosingTime);
            PlayDoorSound(CloseSound);
        }
        else
        {
            NextDoorState = 2;
        }
    }
    
    simulated function PlayDoorSound(SoundCue S)
    {
        if (S != None && SoundComponent.SoundCue != S)
        {
            SoundComponent.SoundCue = S;
            SoundComponent.Play();
        }
    }
    
    simulated function OpenDoor(optional bool bForce = false)
    {
        if (DoorState == 2 || bForce)
        {
            StartDoorState(1, OpenAnimation, DoorOpeningTime);
            PlayDoorSound(OpenSound);
        }
        else
        {
            NextDoorState = 0;
        }
    }
    
    simulated function FinishDoorState()
    {
        if (DoorState == 3)
        {
            SetDoorState(2);
            PlayDoorSound(ClosedSound);
        }
        else
        {
            if (DoorState == 1)
            {
                SetDoorState(0);
                PlayDoorSound(OpenedSound);
            }
        }
        if (DoorState != 4 && NextDoorState != 5 && NextDoorState != DoorState)
        {
            if (NextDoorState == 0)
            {
                OpenDoor();
            }
            else
            {
                if (NextDoorState == 2)
                {
                    CloseDoor();
                }
            }
        }
        NextDoorState = 5;
    }
    
    simulated function OnToggle(SeqAct_Toggle Action)
    {
        if (Action.InputLinks[0].bHasImpulse)
        {
            OpenDoor();
        }
        else
        {
            if (Action.InputLinks[1].bHasImpulse)
            {
                CloseDoor();
            }
            else
            {
                if (Action.InputLinks[2].bHasImpulse)
                {
                    ToggleDoor();
                }
            }
        }
    }
    
    // ScriptText: TextBuffer[26]
    replication
    {
        if (Role == 3 && bNetDirty)
            DoorState;
    }
    
    defaultproperties
    {
        // child object FaceAudioComponent of type AudioComponent
        // child object SoundComponent0 of type AudioComponent
        // child object MyLightEnvironment of type DynamicLightEnvironmentComponent
        // child object SkeletalMeshComponent0 of type SkeletalMeshComponent
    }

    Leave a comment:


  • replied
    Thank you guys! This was very helpful!
    I had already figured out the collision stuff.. mostly, but was getting an error while building my level and it was due to the fact that I hadn't checked PhAT!

    Now I am working on a new door that's mechanical and slides though.. This has brought on new issues:
    -It's a Skeletal Mesh
    -Slides on the X axis left and right
    -What would be the 'door knob', I guess, rotates before the door slides
    -Some gears turn throughout the animation

    I've created and animated this door in Blender, exported it as an FBX to UDK the same way I had done my first door which works.
    BUT! When I hook up the anim tree and get everything working in UDK it seems to have an issue that my other door didn't have:
    The animation doesn't seem to complete.. Or rather, the 'knob' turns correctly and the door slides the correct direction, but it doesn't slide fully open?

    Anyways, I know that this is an old thread, but maybe somebody will see my post and point me in the correct direction (where to find a similar post, etc.)
    Thanks everyone! Love this community. <3

    Leave a comment:


  • replied
    Thank you sooooo much that was exactly what I needed to know. I didn't realize I had to use PhAT to create a physics asset in UDK I was trying to do it in blender with the UCX_ prefix.

    Edit: Is there a way to mark a thread as solved here?

    Leave a comment:


  • replied
    Ah ok. So you need to make a physics asset for your door, apply it to the skeletal mesh and make sure "has physics asset instance" is checked on in the properties and adjust the collision properties where needed. You may need to turn on "block rigid bodies" though I'm not 100% on that so save that part for last.

    Leave a comment:


  • replied
    It appears the page ate my last reply.

    I can do that for some doors like a normal house door.

    However I'm trying to create more interesting doors with moving and sometimes organic parts that aren't easily animated with simple translate and rotate operations. Specifically vines with IK chains that uncurl from around a locking mechanism.

    I tried setting the collision property to block all in the skeletal mesh instance, but I still don't collide with it. I think I need to add some collision primitives and hook them up to the door's rig but I don't know how.

    This is for an adventure game so I don't need super detailed collisons with the walls. Indeed most of the other wall sections I've made used just a simple stretched cube for their collision skin. I just need to keep the player from going through the door.

    Leave a comment:


  • replied
    Oh you're using a skeletal mesh for the door? That's not needed at all. Just make a separate door mesh with the pivot point on the edge of the door where the hinges would be and use it as an interp actor and set matinee to rotate the door 90 degrees for the opening animation. No need to use bones for a simple animation like that. A Skeletal mesh is better suited for objects with more complex animation and deformation, not just rotation.

    Leave a comment:


  • replied
    How do I add an interp actor for a skeletal mesh? I thought that was only for static meshes.

    Leave a comment:


  • replied
    When you make the door an interp actor, there is a setting for collision in its properties. By default it is set to COLLIDE_none. Change that to COLLIDE_BlockAll and you should have your collisions.

    Leave a comment:


  • Need help getting animated door from blender to UDK

    Sorry for the long post I did a lot of experimenting while waiting for my account to be approved and came up with more questions.

    I'm digging the modular design thing. I created some wall pieces for an office scene all in blender. They export fine as static meshes. I build collision skins for them in blender and those export fine as well. I build a little demo level using these pieces and some bsp geometry for the floor. I added some lights, hopped in the level and it was all great apart from some messed up normals and smoothing issues, but those are mostly worked out.

    Then I tried to add a door. My "door" asset is a section of the wall with a door in it. This door is animated. It functions sorta. I fought with the export import process for a couple hours before I got one that worked, but the scale is still wrong. I'm using blender units and assuming 1 bu is 1m. In UDK I'd like 128uu to be 1m so I scale my models up by 128 in the fbx exporter. I can tolerate scaling the door up in udk. However I can't seem to get any kind of physics working with the door. I'd like the door to stop the player from walking through it and ideally gently push the player out of the way if it opens toward them.

    Currently I'm using a touch trigger to play the animation via matinee and kismet. I'd like to do a UI popup and make the player press a key to activate the door, but I haven't bothered with that because I can't get the door to work right yet.

    Questions:
    1. Can I make a collision skin like for static meshes and just animate that? If so how? It didn't seem to work for me.
    2. If that's not possible, then how can I make the door a separate static mesh and rotate it around it's pivot but still have it snap to the grid in the door frame? It seems like UDK wants to use the mesh's local origin for everything so if I slide the door to where it will rotate around it's origin then I can't snap the door into the door frame and vice versa.
    3. What's the sane normal way to do this?

    ~Tom
Working...
X