How to get an offset from an actor in level without vector or arrow component ?
Hi everyone im working on a project, in which i need to place actors (buildingparts) in the level. The buildingpart class contains a static mesh and arrays of transforms which are the offset values.
There are two actors of that class involved in that situation: Traced actor is already placed in the level and current actor which is the one i want to place next to traced actor with the offset.
In PlayerBP i have a custom event that does a sphere trace each frame as long im trying to place down the current actor, then it adds the offset to the location of the traced part. The offsets are x and y axis values.
Now to the problem, this method works as intended as long the traced parts rotation is -180 -90 0 90 180 but as soon as the traced part is no longer on 0 0 x y rotation the offsets no longer work as they should i know that the locations are no longer the same as my math just adds x and y values when its rotated.
Soi tried out to work with arrow components in the buildingparts and that worked pretty well but the problem here is that some buildingparts have a big amount of possible "snappoints" and if there are maybe 100 or 200 of these parts present in the level it may cause performance problems.
In the screenshots you can see those blueprints and the results in the viewport The first image shows the custom event which adds the offsets and saves the final resulat as a transform.
The second image shows another event which does the same but it takes the information for the offset not from class defaults of the buildingpart it does take them from the arrow components in the buildingpart. There is only one of them wired up at the same time, its just a different approach.
on both viewport screenshots the left 3 cubes were placed with a 45 degree yaw rotation while the left 3 cubes were placed with a 0 0 0 rotation as you can see on the first image when im using the transform version they get not placed where they should be when rotated. on the second one you can see the result with arrow components which is how it should look.
Is there a way to achieve the result of arrows with only math? if yes how would i approach that ?
I readed into vector use in ue4 but it seems i would have to preset absurd amounts of possible offsets to cover all possible rotations. I need to keep the buildingpart actors as simple as possible while maintaining functionality, thats why i also can't destroy the arrow once a part is placed because you may want to build onto that part later on.
Any suggestions or advice on this topic is welcome and appreciated.
Thanks for your time and have a nice day.
asked Jul 14 '18 at 04:20 PM in Blueprint Scripting
All things are possible through math, my son ;) If I'm understanding what you're trying to do, you need to rotate the offsets from the old part using the rotation of the part they belong to. It looks like you're rotating the new part, but not the offset from the old part. You can use the 'Rotate Vector' node with the rotator input being the rotation of the old part, and if you only want two dimensions, just leave the Z of the input vector set to 0. If the origin (pivot point) of your parts is not in the center of the mesh, it will complicate things, but the idea is still the same.
Hi it seems so :P today i tried again and used instead of transforms saved in the part class, the nodes get actor forward.right and up vector and then multiply those by float variables from the part class which make in groups of 3 (x y z) the offset locations. It works on any rotation i tried so far.
Because the offsets get now recalculated every time a compatible part is traced the offsets no longer need to be adjusted Also the rotation is taken from the traced part and the player input rotation is added.. But thanks for that hint with the "rotate vector" node that will be usefull in other cases :)
I added some screenshots in case someone is interested how i setted the new event up.
first the trace which gets the class of the old part and compares the classes and determines which set of snappoints is needed. After that the snapsets get splitted up and the needed snappoint gets selected by another integer the player can choose.
On the last image you can see that the cubes now snap in the right offsets no matter which rotation the traced target actor has also the rotation is now correct and can also be adjusted .
answered Jul 15 '18 at 04:47 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here