Trigger box edge triggers beginning and ending timelines - unreal-engine4

I am making a game and I want door to open when I enter trigger box and close when I am exiting it.
The blueprint of the door
The timeline of door sliding(both enter and exit use same timeline just exit uses reverse)
When I am at the edge of the trigger box, it just glitches and cannot decide if the door should close or open.
Is there a way to put a deadzone or some kind of filter to prevent this from happening?
Thanks!

It would seem to me that at least part of the problem is that you have two timelines fighting each other.
It makes more sense to have a single timeline, and play it to open the door and reverse it to close the door.
So, delete everything after the bottom overlap event and instead run its execution pulse into the 'Reverse' input of the timeline at the top.
You should also use the Play input on the top timeline instead of the PlayFromStart input. Otherwise, if the door is still closing when you re-enter the trigger box, it will suddenly jump to the closed position to play the opening animation from the start.

Your screenshots are somewhat difficult to read, however I will try to answer:
Make sure the event that fires when the actor leaves the box happens correctly and that it STOPS the current animation from playing. What's happening is your actor's location may be "bouncing" between entering and exiting the event box.

Related

moveTo on "On task suspended" doesn't work

I have a dock as an static resource and I want to move the current ship in the dock to a waiting area when a ship of higher priority arrives (the dock can only attend one ship at a time. Ships are the agent in the flowchart). To do this, I allowed preemption in the seize block (the one that seizes the dock) and on it's "On task suspended" box I wrote the code:
agent.moveTo(waitingArea);
When the ship of higher priority arrives and suspends the task of the current ship, the current ship remains without movement in the dock, the new ships gets to the dock (on top of the current ship), and only after a few seconds (hours in the model), the current ship jumps to the waitingArea like if the code was jumpTo instead of moveTo.
Not only the movement is not being shown in the animation (just jumps) and the movement (jump) is being executed with an extrage delay, but also, later in the model run I get the error "Can't set arrival callback during movement".
If I remove the code described above from the "On task suspended" box, the error doesn't appear, but of course the animations of the ships would overlap like if there were two ships in the dock one on top of the other and that's what I don't want to happen.
Any idea on what is happening and how to fix it?
Try not writing the code in the pre-emption section.
Instead, continue the flow chart out of the pre-emption port and use a MoveTo block to do what you need:
Always make sure you understand all ports of your blocks so you can use them when needed.
Seize-block help is here.
I solved all the points as follow:
To allow the animation to occur instead of jump, I had to remove the delay block location propertie and leave it empty. Apparently the moveTo code doesn't override the location entered in the block properties, but the destination of the moveTo code does (unintuitive behaviour in my opinion).
The strange delay before the jump occurred was the time of the "invisible" movement the ship was doing, so when the ship "arrived" to the waiting area the jump was executed by the animation. With the above this point was understood and solved.
Finally, the error occurred because while the ship was returning to the dock from the waiting area, the delay time ended and the next block was a moveTo block, so the ship received two moveTo instructions at the same time (the one from the "When task resumed" and the one from the moveTo block after the delay). To solved this, I had to enter a code that paused the delay countdown until the ship was in the dock again, and then resume it.

object in unreal engine disappear?

enter image description hereso im basically new to blueprints and i am trying to make a game based on collecting trophies and i finished the code, but for some reason when i drag and drop the trophy it disappears, that wasnt an issue before, im also trying to randomize where the object spawns and i was succesful but after i made changes to the trophy code, suddenly it wont spawn at all, here are some screen shots. enter image description here
As I see you are destroying object on overlap, right before you respawn the object, you should destroy the trophy only after you spawn new, so destroy function must be called at the end, when other logic is finished.
And the best way to handle such operations is some kind of manager. You may use game mode, level, player controller as trophy manager, anything that will exist from the beggining of play and till the level is closed.

how to reference an "armature action" of a bow using code?

I'm trying to make a bow and arrow game. I downloaded a bow that has an animation(?) on it where the string is pulled back.
See:
I want to make a script that triggers that animation (shown on bottom-right of my gif) when Player left clicks. But I don't know how to reference the animation.
Is it something like _anim = GetComponent<Animator>(); and then animation.Play? I cannot tell what the name of the animation even is to do this.
Further.. it would be awesome to be able to control the animation's length depending on how long the user has held down the button, rather than playing it in full even if user only taps left click. I'm not sure how that would be achieved?
Ok, the question seems short but the solution will be long and you need to do a bit of learning. So, let's go through your question step by step.
I downloaded a bow that has an animation(?)
Yes, it is a 3D bow model with an animation in it.
I want to make a script that triggers that animation (shown on
bottom-right of my gif) when Player left clicks. But I don't know
how to reference the animation.
In order to trigger that animation, you need an Animator Controller attached to the bow model instance. Then you can click that Animator Controller to open its panel. After opening the panel, you can simply drag and drop your animation there. When you first drop your animation, it will be the default animation state. However, if you don't want to trigger the animation immediately, I would suggest you to create an empty state and make a transition to the bow animation.
Is it something like _anim = GetComponent(); and then
animation.Play?
More or less like this, but you should check the documentation for better understanding, this documentation explains it well and has a really good example for your use case.
I cannot tell what the name of the animation even is to do this.
Once you drag and drop the animation to the panel, you will see the name of the animation to use in the script.
Further.. it would be awesome to be able to control the animation's
length depending on how long the user has held down the button,
rather than playing it in full even if user only taps left click.
I'm not sure how that would be achieved?
There are many ways to play with animations, for example, you can set an animation parameter to stay in the animation state. Furthermore, you can also disable the Has Exit Time value from the transition to make it stop the animation immediately after the user stops holding the button.
Overall, when it comes to animations, Unity is quite powerful and my suggestion would be read the documentation and watch a couple of tutorials.
Hope this helps.

Interaction with object by pressing E button using ue4 blueprints

I am a begginer in ue4 blueprints system. I've wanted to create simple code: player enter the trigger box, and press E, after that text should appear on the screen. What I did wrong in my code?
I'm no expert, but I think you should use a branch node to check if the key is pressed. No harm in also changing your other character to a getplacyercharater.
Best of luck :)
On Component Begin Overlap (Box) fires on the frame you begin overlapping. Unless you pressed E on the same frame you begin overlapping, this will not work.
For this to work, you would have had to be checking if it was overlapping and for the key press on every tick. Don't do that, it's a waste of time.
What you could do instead is On Component Begin Overlap, set a variable to record that you're ready to interact, and then check for that variable when you press E.
This is something I did recently using the Top Down template that demonstrates 'move within distance of object, press button, thing happen'
Adding an object to a 'ready to interact' array on overlap in Player Character.
Detecting a mouse click, checking if it was in the array, doing stuff in Player Controller.
It sounds like you're building an interaction system though, so if you want this to be as re-usable as possible you should probably have this code on your Player Character / Player Controller, and not in the object you're interacting with.

UE4 Enabling Mouse During Play?

I'm extremely new to UE, and doing a few easy tutorials to get started, so I don't exactly know the correct terminology to use to help me find what I am looking for... Anyway, whenever I hit play and the game starts, my mouse disappears and I am only able to use the input that I set up; so my question is, even though I do not need mouse input for movement, as I am using WASD, how do I keep my mouse unlocked and available to move around without being locked to the camera?
When you hit play and the game starts, your mouse gets captured by the game to control the camera. If your play button is set to play in the viewport, you can release the mouse from the viewport by pressing Shift-F1. The game will still be running, but input (including from the keyboard) will be suspended and you can interact with the editor.
You can also change the default behavior of how the mouse is captured and it if is constrained to the viewport boundaries. To see these options, go into the project settings (settings button above main viewport/project settings...). On the left side of the project settings window, select 'Input' under the Engine heading. On the right side will be some mouse preferences that can change its behavior.
For instance, to allow the mouse to travel outside the viewport, change 'Default Viewport Mouse Lock Mode' to 'Do Not Lock'. I don't recommend this, but you might experiment with these to get a feel for what they do. Also, you might look up these settings in the Unreal documentation for more detail.
There are 3 blueprint nodes that change the input method:
Set Input Mode Game
Set Input Mode Game and UI
Set Input Mode UI
You want a combination of the second one and a "Show Mouse Cursor" node. However, if you are making an FPS and you use the mouse to look around, you may lose that ability with the second node above. It comes down to what your game is and how you want to use the mouse.
I had the similar issue. So I did something like this in Level Blueprints to achieve what I want.