playMaker

Author Topic: Random Object (More than one)  (Read 5854 times)

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Random Object (More than one)
« on: January 23, 2014, 04:20:33 PM »
Hi!
I try to figure it how I can make objects appear randomly on the random points without appearing in the same random point. I was thinking if I destroy the random point when an object appear on it, so no other objects can appear on them. So the question is: How can I destroy the random point each time an object appear on it? I can't just destroy a specific random point, since an object doesn't appear on a specific one

Do you understand what I mean?
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Random Object (More than one)
« Reply #1 on: January 23, 2014, 04:31:22 PM »
Do you understand what I mean?

Nope.

So far we have random points and random objects, but they're not in random points? What is the random point?... Its pretty hard to understand what is actually going on.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Random Object (More than one)
« Reply #2 on: January 24, 2014, 01:08:23 AM »
Ok, sorry! I should maybe explain a little bit more details.
Random points is just invisible Game Objects I use where all those objects will appear on. I just call them for Random Points. You can call them whatever you want.
And I place these Random Points as a child. Then I use Get Random Child.

For example, I have a bomb with number 1 which will appear on one of these Random Points. For example Random Point 1. And this Random Point 1 will be destroyed after the bomb appear on it, so other bombs doesn't appear on the same Random Point.

Do you understand now? :)

I don't know if this works. I just try to figure it how I can make more than one object appear randomly without appearing at the same Random Points.

I heard that I can use Arraymaker for this, but I need a step-by-step tutorial on how to use Arraymaker, so forget that. :)
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Random Object (More than one)
« Reply #3 on: January 26, 2014, 06:29:39 AM »
I found a way to do it. But I should wish someone could tell me the way they would do it, because I'm sure it is a better way to do it. :)
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Random Object (More than one)
« Reply #4 on: January 29, 2014, 02:48:51 AM »
Hi,

 I don't see anything wrong with your approach if you want to control these random points position during development and make sure they are reusable, so that's ok as far as I can see.

bye,

 Jean

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Random Object (More than one)
« Reply #5 on: January 29, 2014, 09:53:31 AM »
Hi jeanfabre!

But the problem with this is that if I destroy all the random points where the bombs will appear on, it can happen that two bombs appear at the same random points, so I made a delay for each random point. So the bombs will appear every 0.2 seconds.

If you have some ideas how to make them appear at the same time, tell me! :)
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Random Object (More than one)
« Reply #6 on: January 30, 2014, 04:57:17 AM »
Hi,

 then I would try the following approach.

Create linear movement of dummy gameobject at different heights, so they never intersects and use a random time to poll for the current position of that dummy and use that as a position for the bomb placement.

can you give us more info on the type of game and how bomb fits on screen? are they falling or simply in place?

bye,

Jean

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Random Object (More than one)
« Reply #7 on: January 30, 2014, 03:59:56 PM »
Hi!

The bomb placement will be simply in place. Like in a memory game when you need to fine two matching cards.

But can you explain me more? I didn't understand entirely.
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Random Object (More than one)
« Reply #8 on: January 31, 2014, 07:40:21 AM »
Hi,

 Forget it if it's in place.

 what you wil need is a manager that will record a specific spot as being already taken.

 typically, what I do for these cases is use ArrayMaker.

I have an one array that contains ALL possible position. I duplicate that list and use it as a pool, everytime I pick one position on this duplicate I delete that entry, then next time, I can not pick it again since it's not listed anymore, and I go trhough that list until there is no more entries or when I don't need bombs anymore.

Does that make sense?

bye,

 Jean

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Random Object (More than one)
« Reply #9 on: January 31, 2014, 10:21:17 AM »
Hi!

I took a little look at ArrayMaker now, but I have never used it before. I don't know which Actions I need and so on. Maybe you need to help me through this, because I really want to learn ArrayMaker.
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Random Object (More than one)
« Reply #10 on: February 03, 2014, 07:20:41 AM »
Hi,

 Have a look at this sample ( Requires ArrayMaker). It's an object pooling example showing you how to pick objects making sure you don't pick them twice.

Basically, you can apply the same process to your random picking. you can use vector3 positions instead of objects, and instead of hiding them you simply create your bomb on that vector 3 position you picked from the pool.

 This sample will be on the next ArrayMaker Package.

 Bye,

 Jean

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Random Object (More than one)
« Reply #11 on: February 04, 2014, 01:03:39 AM »
Hi!
Thank you! I will take a closer look at it later.

Just a question!
When I click with the mouse button, the objects appear randomly, but in the same position every time. Is it possible to make them appear in random position?
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Random Object (More than one)
« Reply #12 on: February 04, 2014, 04:45:23 AM »
Hi,

 Yes, you can extrapolate on this. Basically, this gives you a system to pool from a list of variables, they can be objects, or actual vector3 position. then you can use that position to spawn what ever you want: bombs for example.

the random positions is actually a list, this is the only way to guarantee that you won't spawn on the same location. A variation of this would be to make sure these list of positions are always more then x units apart, and based on the picked position, you add a try random vector on top of it, making the final position really random, within a certain range of the picked position. This way you ensure unique spots, as well as randomization of the final position.

bye,

 Jean