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"

cast from player character BP to ai character BP?

cant find a solution for this, trying to cast from player-character blueprint to ai-character blueprint, what is the object i have to link here?

what i want to do is fire a custom event in ai-character BP when i press a key as the player or is this not possible?

alt text

Product Version: Not Selected
Tags:
cast-object.png (76.2 kB)
more ▼

asked Nov 30 '17 at 08:41 AM in Blueprint Scripting

avatar image

endbored
41 8 7 13

avatar image cahitburak Nov 30 '17 at 10:42 AM

If you want to cast this blueprint to EnemyZombie1 then connect "self" to object input. But your AICharacter BP must be inherited from PlayerCharacter BP and it must be instantiated as EnemyZombie1 when created.

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

3 answers: sort voted first

well you can't just say cast to or send an interface message to and not give it a target. The engine has no way of knowing which object you are referring to. If this is for testing purposes, you could make an actor variable, set it to public and then set it to the object you want to affect in the defaults section of the objects settings in the level editor. (you can't set the default values of actor variables in blueprints, its silly.) "Does Implement Interface" and the interface message and casting needs this actor reference. (thats why you are getting errors on your cast and your message) This will affect ONE specific zombie. I get the sense you want to affect ALL zombies, so for that just use "Get All Actors of Class", which will return an array. Use a foreachloop on the array and cast to each one or fire a custom event in each one or whatever. But to be clear, you must hook up the actor coming out of the foreachloop to the target or object of what you are working on. The engine cannot cast or use interfaces if it has no clue what actor its trying to get to.

more ▼

answered Nov 30 '17 at 11:46 PM

avatar image

aqkotz
144 2 8 10

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

got it working now, for each loop was not necessary, i dont know if its the best way or has other disadvantages but so far it works. thanks for your help guys

here the working setup if anyone interested

alt text

solution.png (64.2 kB)
more ▼

answered Dec 01 '17 at 11:02 AM

avatar image

endbored
41 8 7 13

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

A cast casts to a specific class. It looks like your class is EnemyZombie1. You have to tell the cast which actor of the class you are referring to. Try making an actor variable and setting the default to whatever it is you want to cast to and plugging it into object. If you want to cast to the class, use cast to EnemyZombie1 class.

However for this type of thing I would not use casting at all. I would use blueprint interfaces, which are used to create events in other classes. Heres a helpful video on those: https://www.youtube.com/watch?v=G_hLUkm7v44

more ▼

answered Nov 30 '17 at 12:24 PM

avatar image

aqkotz
144 2 8 10

avatar image endbored Nov 30 '17 at 03:22 PM

sorry guys im a rookie and still cant get this to work

Answer1: setting to self did not work for me, i guess it has to do what you said with inherited and instantiated, but i dont know what that means, could you explain that any further or show pics how to set up? ![alt text][1] [1]: /storage/temp/222030-castfail.png

Answer2: i remember that i once used the interface-thing in relation with projectile and enemy damage, but that works with overlapping stuff, and as you can see i still have a target to set up that i cant figure out how to do, in the video he is working with overlapping, but in my case there does no overlap happen, i want to press a keyboard key and have that fire the custom event in the AI Character BP (to stop AI movement)

alt text

castfail.png (62.0 kB)
interfacefail.png (54.7 kB)
avatar image cahitburak Nov 30 '17 at 08:56 PM

You need to learn more about BP inheritance. You can take a look at this link as a starting point. https://docs.unrealengine.com/latest/INT/Resources/ContentExamples/Blueprints_Advanced/2_5/

(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