Value from Blueprint to C++ Script
Hi, I am very new to unreal and am needing to fetch the location and rotation of a premade blueprint Actor. The Actor in question is the build in VR Blueprint "MotionControllerPawn". I need to be able to take the position and rotation of both the HMD and the 2 motion controllers to be used in other C++ Scripts. If anyone has any experience with fetching location and position from a pawn for use in a C++ script it would be much obliged. Added bonus if you've worked with VR before!
I suppose my main question is "How do I get a value from a Blueprint, to a C++ Script?"
Thanks in advance!
Most easiest one is to make base class for MotonControllerPawn in C++, make variables with BlueprintReadWrite and set varables in blueprint. You can also grab locations of your actors from C++, possed you can easily get from player controller otheres need to be set say way as i mentioned above.
answered Jan 21 '19 at 10:57 PM
If you are trying to get a reference from an Actor placed in the level (which means you do not have a reference to it yet like you would if you had Spawned it), then there are several ways you can find the actor you seek, and then save the reference to it.
I noticed that GameMode tends to fire its Init event whenever a Level loads. You could use that or any other blueprint which has an event that reliably fires when a level loads, and use a function such as GetAllActorsWithTag, and make sure the placed actor in the level has that Tag. Then it will be in the array returned by GetAllActorsWithTag, and you can save the reference to it when you find it in the Array, and use that reference from then on so you don't have to ever look for it again (as long as it isn't destroyed and re-spawned at any point, or no travel to other levels happens).
Another node you can use is GetAllActorsOfClass, but using the Tag version lets you be very specific as to which specific Actor you want, and I hope this also cuts down on how many CPU cycles it requires during that first Tick (to avoid making your game slow down or freeze while initializing).
answered Jan 22 '19 at 04:14 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here