playMaker

Author Topic: Getting distance from multiple items placed.  (Read 1288 times)

Karin

  • Playmaker Newbie
  • *
  • Posts: 18
Getting distance from multiple items placed.
« on: August 07, 2020, 08:14:43 PM »
Hello everyone

I'm unsure how to get multiple distances continuously with each object placed by the player.

For example, If I was to use (get distance) after creating an object, how would i prevent that action from being interrupted if I was to repeat that action again with a new object?

heavygunner

  • Sr. Member
  • ****
  • Posts: 344
Re: Getting distance from multiple items placed.
« Reply #1 on: August 07, 2020, 11:46:36 PM »
In this case, this is what I will use.

1. Will use "Get Owner" action and save player prefab on a global variable.
2. will add "Get Distance" action on created prefabs and will store distance between Player (Global var) and created prefab.

What do you want to do exactly ?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Getting distance from multiple items placed.
« Reply #2 on: August 08, 2020, 04:52:23 AM »
Hi.
You can have a array where you can add objects you want to check the distance from.
Then loop the array to get the distances.

or you can have a fsm on the spawned objects to get the distance.

But if you have lots of objects you might not want to do this every frame.

Karin

  • Playmaker Newbie
  • *
  • Posts: 18
Re: Getting distance from multiple items placed.
« Reply #3 on: August 08, 2020, 06:18:51 AM »
In this case, this is what I will use.

1. Will use "Get Owner" action and save player prefab on a global variable.
2. will add "Get Distance" action on created prefabs and will store distance between Player (Global var) and created prefab.

What do you want to do exactly ?

The goal is to detect all created objects that are going out of bounds from a vector 3 translation of X, Y, Z and remove them. The additional condition I gave the created objects was 100 float. So when it reaches that number it will destroy the object. At the moment it was will destroy the last object created if the process is repeated, which leaves the other created objects that are moving away in limbo.

Your approach is interesting I'll give this a try. It does sound like I may need to class some sort of Array proxy on the Manager or Player to keep record.
 

Karin

  • Playmaker Newbie
  • *
  • Posts: 18
Re: Getting distance from multiple items placed.
« Reply #4 on: August 08, 2020, 06:35:48 AM »
Hi.
You can have a array where you can add objects you want to check the distance from.
Then loop the array to get the distances.

or you can have a fsm on the spawned objects to get the distance.

But if you have lots of objects you might not want to do this every frame.


Yeah, I think the clean way is using the array proxy. Heavygunner had the right idea. Because from I can tell, storing multiple prefabs on a global variable would definitely require some sort of array/ array proxy.

Think about this scenario. If I had a crate of different objects that were deliberately untagged, and the crate emptied all the contents on the ground, the system I have right now would only capture the distance of the last object. By adding an array it should keep the process more consistent.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Getting distance from multiple items placed.
« Reply #5 on: August 08, 2020, 08:58:11 AM »
Hi.
You might want to use Array Maker, if you regularly need to add/remove items.

Array maker is more flexible that the build in array.
Also more easy to access from other objects/fsms.

heavygunner

  • Sr. Member
  • ****
  • Posts: 344
Re: Getting distance from multiple items placed.
« Reply #6 on: August 08, 2020, 02:03:10 PM »
Hi.
You can have a array where you can add objects you want to check the distance from.
Then loop the array to get the distances.

or you can have a fsm on the spawned objects to get the distance.

But if you have lots of objects you might not want to do this every frame.


Yeah, I think the clean way is using the array proxy. Heavygunner had the right idea. Because from I can tell, storing multiple prefabs on a global variable would definitely require some sort of array/ array proxy.

Think about this scenario. If I had a crate of different objects that were deliberately untagged, and the crate emptied all the contents on the ground, the system I have right now would only capture the distance of the last object. By adding an array it should keep the process more consistent.
Looks like you mis understood me. :D

Store the Main player only on global variable. Then, put get distance action on created prefabs and get distance between Owner (created prefab) and player.

and Write another FSM on created prefab and use Float compare action. When it equals or greater than 100, destroy that prefab.