Announcement

Collapse
No announcement yet.

Blueprint only works for one enemy created

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Blueprint only works for one enemy created

    I’m very sorry if this is a silly question, but I find myself stuck on a blueprint issue.

    As a self-assigned study task, with the goal of improving my skill at blueprints, I have attempted to create a step-based, first-person movement system (somewhat like Etrian Odyssey) with larger, spidery-looking-security-camera enemies which should respond after the player takes a step, checking if the player is in their line of sight, and either prepare to fire a ranged attack if so or turn away if not. I have managed to get this working well for one enemy, but only one – as soon as I add more enemies using the same blueprint into the level, one (seemingly chosen at random, and not always the same one) acts according to the blueprint, whilst the others stay idling into one direction. I do not understand why this is, or what I should do to fix it. Please could anyone help?

    Click image for larger version

Name:	Image1.png
Views:	1
Size:	393.3 KB
ID:	1188020

    Image 1 – Move controls for the first person character, calling the problematic ‘EnemyCheck’ function after a step has been completed. I know that there is an error on this, and believe that it is caused by something in the way that I connect the object cast to the ‘SpiderCam’ actor in the EnemyCheck function, but all changes I have attempted to make to it have resulted in the blueprint no longer working.

    Click image for larger version

Name:	Image2.png
Views:	1
Size:	339.8 KB
ID:	1188016

    Image 2 – The EnemyCheck function, casting to the SpiderCam enemies. Is it something in this that’s causing the problem? I’ve tried getting all actors of class, or casting to the entire class, but the casting to the entire class will not compile, and the one I’m using currently, ‘get all actors of class’, still seems to work for only one enemy.

    Click image for larger version

Name:	Image3.png
Views:	1
Size:	445.0 KB
ID:	1188017

    Image 3 – The ActionSpiderCam function used by the SpiderCam enemies when they are called to by the EnemyCheck function.

    Please would it be possible to ask for an explained answer? I don’t feel that I’m very good at blueprints yet, and am worried that I may not know technical language or lack knowledge of a process everyone else may understand.

    Thank-you very much in advance for your help, and I am very sorry for my lack of knowledge.
    Attached Files

    #2
    It works for one enemy because you are getting 0, just one actor in the array. After get all actors of class, drag off the array output and do a for each loop, drag off the actor result and do your action spider cam and output. I don't know if you can do a forEachLoop in a macro, I think you can, but if you can't you might have to put that in a function.

    Comment


      #3
      Hi Bitteralmondtea,

      As James mentioned above, at the moment your macro in image two is only going to effect the first item in the array of actors attained from your 'Get all actors of class' node.
      What I suspect you need to do is add a ForEachLoop after getting all actors of class and then wire in the array pin from the 'get all actros of class' node into the array pin of the 'foreachloop'.
      Then you will need to wire the Loop Body pin to the SpiderCam action and your array element then becomes the target.

      Essentially, the foreachloop allows you to loop/run through all instances of that actor and execute the same action, which should solve your problem.

      Let me know if this does not work and I am sure we can come up with something .

      Connor.
      Twitter: ItsConnorReid

      Blueprint Tutorial | Basic Sprint - Beginner Friendly | Forum | Wiki
      Blueprint Tutorial | Stamina Decay/Regeneration Implementation | Forum
      Blueprint Tutorial | Stamina/Progress Bar Implementation | Forum

      Comment


        #4
        I'm very sorry for replying so late - this was a holiday project, and after term started again I became sidetracked by other work - but this fixed my mistake: thank-you so much to both of you.

        Comment

        Working...
        X