Spawn Actors with Spawned Regions use same Region Attribute

LtVax27

  • *
  • Posts: 85
This is for a farming code, It spawns the tree's and each tree spawns a Region and sets it to an Attribute, only the 2nd tree spawned seems to have a Region. Are they interfering with each other?

Scene Behavior


Actor Behavior


I need to spawn them to track individual times and know what number they are.
I can use a 'Keyboard Event' to interact when 'Actor' is inside 'Region', but if I use an 'Enter Region' it wont 'print'

morphman86

  • Posts: 141
I don't know what Row 1 Y's value is, but if either that or Row Depth Count 2 is 0 at the beginning, the Y position will be 0 for the first created actor.  You are then trying to create a 28 pixel high region at Y 1 (Y of self (0) + 1).

That could be why your first tree never spawns a region.

And if Row 1 X is less than 74  (the 60 width and the 14 you subtract from it) you'll get the same problem. In fact, if it's less than 14, you'll try to spawn the region outside of the scene completely.
Programming equivalent of Jack-of-all-trades

LtVax27

  • *
  • Posts: 85
The row Values is set to begin at 32x32 going down for the 1st row, it's the 1st tree in the 2nd row that only has the region, the size of the region is set to prevent overlapping or touching and seems fine on that tree. I tried drawing a rec around them but they never seem to line up. (draw at x-y of region or if I draw at x-y screen of Self)

LtVax27

  • *
  • Posts: 85
This is what i get trying to draw the location of the regions for debugging.

None seem to go where they should (Tree) nor do I know why there are 32 gaps between.

morphman86

  • Posts: 141
I just saw that you're trying to use screen space for creating the regions. Positioning for actors, regions etc. always takes place in scene space, not screen space. Screen space is mostly for UI and such.

If a region was positioned by screen space, then it would move with the camera, never letting the actor actually reach it (a bit like a carrot on a stick in front of a donkey) in games where the camera moves.

Try changing all "x(Screen)" to just "x" and do the same with y for the Create Region and see if that helps.
Programming equivalent of Jack-of-all-trades

LtVax27

  • *
  • Posts: 85
So I set them all back and still got the same result due to the screen being the whole scene but thanks for that reminder.
I tried to get the exact numbers and show them but that isn't working right either....
The numbers are good but the locations of the Recs are wrong so that makes debugging the region hard.


And still only the 2nd tree working. So is it conflicting or are they not spawning or missing something ect..

LtVax27

  • *
  • Posts: 85
I'll give this a bump as I should have some time to work on it tomorrow. Any info on why only the 2nd tree has a region or why the boxes wont draw at the right spot will help.

LtVax27

  • *
  • Posts: 85
Well I'm guessing that this is one doosy of a problem and seeing as how this is kinda the 2nd post regarding code like this I have decided I will add the region to the Player via Scene Behavior in hopes that it will work (also will cut back on a lot of regions). How ever I would still like to get this working as I have an AI code that dose the same thing assigning each spawned enemy with a region for way-point/player/squad interactions (1-5 enemies only).