x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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!

Product Version: UE 4.21
Tags:
more ▼

asked Jan 21 '19 at 09:09 PM in C++ Programming

avatar image

MrJackio
1 1 2

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

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.

more ▼

answered Jan 21 '19 at 10:57 PM

avatar image

Shadowriver
34.6k 917 164 1095

avatar image MrJackio Jan 22 '19 at 03:11 PM

Thanks for your answer, looking into how to do this now. If you can break it down any more I'd be greatly thankful, I'm completely new to the whole blueprint thing as Im coming from Unity.

(comments are locked)
10|2000 characters needed characters left

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).

more ▼

answered Jan 22 '19 at 04:14 PM

avatar image

mightyenigma
3.7k 18 18 15

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question