I have made under collision / add simple box collision and i try to block all /block dynamic and other settings but i cant find how i can make this to work. Any idea how i can make this one working ? thx
You say you can place traps on top of one another (which I assume you don’t want), but you don’t show how you place them. This can’t be solved with just collision settings.
I’ll assume you have some preview mode for placing the traps along with a key press required to actually place. To prevent placement of traps on other traps, you have to check whether it’s overlapping with any other traps at the moment of the key press. Here’s an example of how you could do this:
Ty, just found another solution or i heard how i should try to fix it with a trace line. But you are correct, i have build mode on then i can place the trap by pressing a key. So maybe either i can try your example for how to do this or with the trace line. So far i dont know how to make either working lol
I’m not sure how a line-trace would help in this situation. Here’s a little more info on this solution:
Place the above code right after your confirmation key you mentioned having. Make sure it’s before the code to actually place the trap, and have the true pin from the branch node lead to said code.
I’ll assume you have a base class that all traps inherit from, or at least a single class that they’re all based on. In the overlapping actors node I placed, set the class filter to that class.
For the Trap variable I have there, that should be a reference to your trap that you’re in the process of building.
Here is what i got from the other guy about the trace line - “You need to Check on the line trace if an other trap got hit.
From there you have to implement logic that prohibits the building of a new trap”
I will try your code in a min. Im acctually not sure about it. Yeah there is a class of traps which they inherit from and awso some preview ghost trap logic befor placing them. It kinda overwhelms me to implement this right now because im unsure how to do it. i may go your suggestion in a sec and see if it will work.
Yeah, that line trace suggestion won’t work. At best, it would prevent you from placing it more than half-way into the other trap. Unless they’re talking about tracing to every single trap ever spawned, but that would be difficult, cumbersome, and extremely badly performing.
The IsEmpty node checks the array and returns a true/false value on whether there isn’t anything in the array. In this case, we’re using it to ensure no overlapping actors were found.
Actually, looking at your code, there’s a better way than having a branch there- you already have one. You’re already checking if you can build, you just need to change it a bit.
Next, create a pure function called “CanBuild?” or something along those lines with a boolean output. You can do this by creating a function as normal, and just checking the pure box:
This is what the interior of the function should look like:
There are likely collision settings you’ll need to change. Just make sure on every trap there is a channel for overlapping. You can create a dedicated channel for your trap placement in Project Settings → Engine → Collision → Object Channels
So if i set the “CanBuild?” to “private” without doing anything else my character stops moving and im getting an error in the third person character blueprint.
That is intentional. It’s fixed later in the message.
Notice how the error says “CanBuild is private and not available in this context”. This means you won’t be able to reference that variable outside the trap blueprint.
It’s so you don’t accidentally use it when there is a proper get function in the form of the pure function I detailed.
You’re replacing CanBuild with the above mentioned function as shown here:
Ok, i have the variable canbuild? not directly on the third person character but elsewhere and it is used in other functions as well. That will be a no problem yes ? If so i will continue then and try the stuff from above.
It’s perfectly fine to use it inside your BPFinalTrapsSnapping blueprint- there won’t be any problems there since it’s declared in the BPFinalTrapsSnapping blueprint.
Just keep in mind to use the function if you need to make sure it also accounts for collision since the bool alone doesn’t.
Though, honestly, with everything I’ve seen, I don’t think you need the CanBuild variable at all. (Also in any case you have two for some reason, so you should delete that second one). But it seems IsBuildModeOn would be all that you need. In which case, you can replace the CanBuild variable in the CanBuild? pure function with the IsBuildModeOn variable. You could then just have the CanBuild node connecting directly to the branch rather than an and node.
The second canbuild must be from an accident. My mouse is double clicking so must be from it a not planned to be in there… how is this array node acctually called where it say empty?
here is what i did not sure if i should use the original canbuild? or do i need to make a new canbuild? extra for this new fuction?
im noob i followed a guide to make this so i have a bad feeling that i may not make this one working. I indeed have collision profiles and im there not sure how to make yours .
The CanBuild? function should be in the BPFinalTrapsSnapping blueprint.
For the is empty node, just drag off of the blue squares labelled OverlappingActors on GetOverlappingActors, and search Is Empty.
Just clarifying that BPBuildFloorTr… is the class that all traps inherit from, right?
The Target on the GetOverlappingActors node should be your trap blueprint actor, not a floor component. I assume you placed the function in the trap blueprint itself, and that floor component is the trap part, but the function should be in the BPFinalTrapsSnapping blueprint.
You did it right, but accidentally made a new trace channel rather than Object channel.
Acctually in the “BpFinalTrapsSnapping…” There is awready some “canbuild” function similar to yours. So i have to make a new one there and put your logic ? because i just created it in the “BpTrapsSnapping…” Or do i replace this function just on the place you showed me because this one is kinda exact the same one only not put there
The system i get is from here so he explain it in detail and i followed it. There is just a small difference on mine but it is only the coordinates where the traps get set after line trace node rest is exactly the same UE4 Base Building / Lets Get Started - YouTube
That CanBuild?Function seems to be you starting to copy the function. You can remove the GetDataTableRowNames node as well as the OutputGet output and then just add in what I showed.
Why does the BP_Final_TrapsSnapping blueprint not have a reference to the trap you’re placing? It spawns both the ghost and the actual actor, but there’s no variable referencing it. That actor is what would be plugged in as the target for the get overlapping actors node.
For the traps, just create a new actor. Name it something like BP_BASE_Trap. Then, go through all your traps and as long as they inherit from Actor, re-parent them to this.
I’m guessing these three actors
Are what all traps extend from, so you probably only need to re-parent these.
I dont know but it works perfectly i see the preview ghost trap and when i press left mouse button it spawns it there so perfect. The logic for to start “build mode” on is in the third person character which is called “BP_TrapsSnappingSystem..” All the logic for the traps is on BP_FinalTrapsSnapping.."
I looked into the video, and I see you do have a reference to it.
As I said, you can’t use that floor reference. Delete it and the GetOverlappingActors node. Get a reference to the BuildGhost variable hidden in your components tab,drag off from it, search get overlapping actors, set the filter to BP_BASE_Trap, drag off from overlapping components and search for the is empty node. Connect the output of that empty node into the return value.