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. 

Getting Reference to Enemy Character

Hello,

I am having a hard time trying to figure out how to get a reference to my Enemy1 Blueprint for my damage calculation Function. I can do it normally with getting a reference to the player controller, but not to Enemy1, which I have made as a Character Blueprint. I feel like I missed something, somewhere...

Here is my graph at the moment

alt text

And here I have one setup for the Enemy1 Blueprint for calculating damage given to the player, whereas the other one was calculating for giving damage to the enemy:

alt text

Any and all help would be much appreciated!

Product Version: UE 4.19
Tags:
more ▼

asked Apr 29 '18 at 11:56 PM in Blueprint Scripting

avatar image

Dylanrockin
1 3 6 12

avatar image Nebula Games Inc Apr 30 '18 at 12:41 AM

How are you "calling" the damage event? For example, is it when the enemy overlaps the player? When a projectile hits the player? etc

avatar image Dylanrockin Apr 30 '18 at 01:14 AM

I plan on making a collision overlap, for debugging purposes, and when the player overlaps it, it will calculate their strength against my character's defense and so on. But, the issue I'm having is trying to get a reference to the Enemy Character so I don't get yelled at by the editor. Essentially what I would put in the Object Wild Card in Cast to Enemy1.

avatar image Nebula Games Inc Apr 30 '18 at 01:22 AM

Yes, I understand the issue haha I was asking because usually the way you get that reference is from something like an "overlap" event or a "hit" event. Those events create a reference to a "hit/overlapped" actor which is what you would use to "cast to enemy". That's why I asked how exactly does your enemy "attack" the player?

avatar image Dylanrockin Apr 30 '18 at 01:29 AM

Ohhh, okay gotcha. Yeah, essentially that's what will happen. However, I have this as a Function that is saved inside of Enemy1. So, I'm assuming for the object wild card an overlap is what I would put there for the cast?

avatar image Dylanrockin Apr 30 '18 at 01:45 AM

I just tested this and it still is throwing a fit. What specifically, node wise, would you want me to use? I tried Overlap BoxCollision, but that didn't work and threw me an error. Not entirely sure what to use for the reference.

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

1 answer: sort voted first

Like this. alt text

referencing.jpg (117.7 kB)
more ▼

answered Apr 30 '18 at 01:43 AM

avatar image

Nebula Games Inc
5.4k 28 9 14

avatar image Nebula Games Inc Apr 30 '18 at 01:44 AM

That "STOP" is a custom event/function or whatever you like you can call afterwards.

avatar image Dylanrockin Apr 30 '18 at 01:50 AM

Hmm... I got it to work, however I may need to play around with the numbers, because it is subtracting health as it should, but it may need some more testing. At least that cleared up one headache, haha. Hopefully.

avatar image Nebula Games Inc Apr 30 '18 at 01:52 AM

Cool, glad it works now

avatar image Dylanrockin Apr 30 '18 at 02:00 AM

The only question that remains is: where should I save this code to? Should it remain in Third Person Character, or should it be somewhere else, since this is calculating the damage that I receive and not the enemy. I can't collapse it into a macro or function, so I'm not sure where the most optimal place for it be is.

avatar image Nebula Games Inc Apr 30 '18 at 02:04 AM

I'd save the damage in the player character. Seems like a good spot, but it all depends on your setup. For this though it seems fine in plaster character

avatar image Nebula Games Inc Apr 30 '18 at 01:47 AM

show me the setup and the error

(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