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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Direct Blueprint Communication issues within "MyCharacter" Blueprint!!!

I'm getting some errors and don't understand why. Here's the situation....

Within my "MyCharacter" blueprint I've created a variable called BP_Basketball that references a "basketball" blueprint I've created. This basketball BP simply has a sphere root component and a mesh component to represent the ball.

In my "MyCharacter" blueprint I've created functions to attach the ball to my character as well as "shoot" the ball (the "attach" function is seen in the screenshot). HOWEVER, after I play in editor and exit, I always get these errors (seen in the screenshot). I KNOW it has to do with the BP_Basketball variable somehow (because if I bypass the whole "set collision" aspect within the "Attach Basketball" function, then I do NOT get the errors).

I just DO NOT UNDERSTAND why I am getting errors here. In general, I seem to be having a hard time with accessing variables and whatnot from other BPs within my "MyCharacter" blueprint.

What am I doing wrong?alt text

Product Version: Not Selected
Tags:
more ▼

asked Apr 07 '15 at 05:17 AM in Blueprint Scripting

avatar image

VagrantProfile
121 19 31 41

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

That variable needs to be set from a cast node, and the ball needs to be in the level when that cast and set happens. Can you show where your variable is being set?

EDIT: Another, more comprehensive answer given based on your questions.

more ▼

answered Apr 07 '15 at 01:14 PM

avatar image

DG Gage
1.6k 62 31 129

avatar image VagrantProfile Apr 07 '15 at 06:16 PM

How do I set that variable from a cast node? I'm always confused as to when / how to use the "cast to" nodes in blueprints.

Also, why won't the above method of trying to communicate with variables within another blueprint work?

avatar image DG Gage Apr 07 '15 at 08:21 PM

Gave you more comprehensive answer that should help you out

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Casting gets the particular instance of a blueprint. Simply creating a variable based off a blueprint is not enough; you must reference the actual object (instance) that is currently within the level. When you do a cast, it is only necessary to do it once, because:

Once you have the new variable that contains the instance, you are able to use that variable from then on to utilize any events, functions, or public variables (if you don't see a variable you want, go to that BP and set the variable to editable) that reside within the instance's blueprint. Anything you do will affect ONLY that instance, so you could have multiple instances of the same blueprint doing different things.

So here's a couple methods for casting. First one involves using a Get All Actors of Class node that will return all actors of the class you specify. You use Get to grab a particular one of the returned array. If you have just one in the level, you're good. Otherwise, you would specify which one by setting the integer value of the Get. Once you have your object, you can then do a Cast to [class of the thing]. Finally, from there, you can drag out and select Promote to Variable to save the instance.

alt text

You can then use that variable to access whatever you need. You also do not need to recast if you need to use that variable at some point further along in the processing order.

alt text

Here's an example that involves casting from an overlap. You check the actor class to make sure it's the right type of item, and then cast to your actor with the result of the overlap.

alt text

And since you mentioned that it's a ball and probably want some physics happening, here is the method for altering the physics of an object in real time. You can't enable/disable gravity and physics on an entire actor, because those properties are based on the components of the actor, and specifically the root in almost all cases.

Take your instance variable from earlier and use Get Root Component. Now, use that to Cast to Primitive Component. You now have direct control over its most basic properties. You can save that as a variable as well, which lets you use that in later processes to control those properties without recasting.

alt text

more ▼

answered Apr 07 '15 at 08:21 PM

avatar image

DG Gage
1.6k 62 31 129

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
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