How to get an actor's specific component with a component blueprint?
So I have a projectile that has a Box collosion component. I created a "CanHarm" blueprint component that applies damage to enemy on hit.
The problem is it kills the first enemy but after that the arrow(projectile) flies away from target (I have a custom homing projectile that's not perfect but it worked without my custom component). Also there is one error message when I stop playing:
I think this is the source of the projectile strange behaviour. Also I tried "Is Valid" stuff with owning actor and the component too (so from "Get Owner" and after the get first item from array).
Do you mean "Accessed None"? That would be caused by the array "Get 0" node. If you have no items in an array (the length is zero) but try to get the first item, you'll get an error. Item 0 is the first item, which is only okay to ask for if there is indeed at least one item in an array. So the bullet is likely hitting something that doesn't have that component on it.
To fix this issue, put in a branch that checks if the length of the array is > 0.
I'm not sure that will fix all of your errors, but at least you'll be able to solve the error message.
answered Apr 19 '15 at 11:15 AM
I have no idea if this is the issue, but have seen that error message more than I care too. When your in a loop manipulating an array, I have seen this message pop up, because the number of items in the array were being altered. In this case, it's always when you remove an item. it feels as if that during the loop the value for the "end index" is not re-evaluated during each loop, but only set, when the loop is first started. (whether you use a For loop or For Each, makes no difference). I could find no "cheap" (i.e. little processing), way to force re-evalution at the top of the loop.
So there are really only two other alternatives,
2.if you are going to modify the contents of an array in a loop, have a temporary loop to the side, that you keep the index of the items to remove from the array, after the processing is done, just hooke the "remove" code up to the completed pin, and get after it.
To me, option 1 is the best way.
Hope that helps,
Jay Ice IceWare
answered Sep 16 '15 at 11:29 PM
Bah, generally for what I was speaking of, the error message will also say something like, "9/5" as well, trying to tell you that you were trying to get the 9th element of an array that only has 5 elements
Well if this is so, how did we ever get the 6th Element without that message if the array only has 5 elements, and how did we get to the 9th element before the message was issued, if we only had 5 elements. i.e. there is no checking of the last index, at the top of the loop.
Now to your issue, yes this does pop up, in general what I found it means is that you have a null value, in the array, hence it's saying "none". I encountered this when doing Get all Overlapping actors, and the same for Overlapping Components. and using the return value to set an array. i.e. UE4 at 4.8.3, 4.9.0 and 4.9.1, is for some reason at times injecting a null into hte array coming back from the overlap request.
In order to circumvent this issue. I wrote a small routine to take an array, check for nulls, and return a new array, that has the nulls removed.
Hope this helps,
answered Sep 16 '15 at 11:35 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here