[SOLVED]Trouble with object instances

Hi, I have several object instances, initially they are hidden. And I assigned the “id” variable to these instances. I need to implement the following - if the instance with “id 1” has a collision with the player, then it becomes visible, and when it is visible, the instances with “id 2” and “id 3” become visible too. This seems simple, but… I can’t figure out how to refer to “id 2” and “id 3” in “action”?

I’m not sure exactly what you’re doing, but I would think you filter them in conditions. You’ll need to use subevents, with the condition Pick all objects as the fist condition of each subevent, and then refer to “id 2” or “id 3” in the second condition.

But just wondering, if instance with “id 2” has a collision with the player, do instances with “id 1” and “id 3” become visible? If so, I’d consider a parent or umbrella id, and using the similar logic as before but making all instances with the same umbrella id visible.

1 Like

Thanks, it not bad solution, but i tried this… it doesn’t seem to fit my idea(

I am trying to implement a primitive optimization method for partial drawing of the level, I divided it into “sectors” and I want the player to see only the pre-created visibility limits when he is in any sector.

Yes, you a right. So I should try to implement this with child variables?

Like in the gif below, or something less permanent, so only show the sector while the player is in there? Either way, how I implemented it was have strips of black overlay the scene. Each strip belonged to a group (identified with the instance variable Id). It also has a sequence number for the cascading reveal.

RoomReveal


This effect is achieved with the following set of events :

and


I’m not sure what you mean with child variables. If you mean adding an extra variable to the objects, then yes.

1 Like

Thanks, this is useful, but a bit different from what I’m trying to achieve. I want to implement something like this, but in a simplified version (for a 2d top view):
(from 31 sec).

This is 2d illustration(simplified method):

The essence of the method is as follows - if the player is in sector “1”, then, for example, he will “see” sectors “2” and “3”, and if the player is in sector “2”, then he should already “see” more - sectors "3 ", “4” and “5” for example.
It is very easy to implement with diffrent objects, but with instances of one object, i have already broken my head :grinning:

Sorry, you mentonied “parents”, that’s why I thought about “child” variables

This is my logic(of cource this not work, it just for example):

Can’t you use Object foreach and compare the id variable? If it fits the desired ids, make that instance visible.

Something like this:

EDIT: If you want to have some sort of “relational” variable, you could have an array variable in each sector listing the sector ids that are connected to it and should become visible when the player enters. Then when player collides with a given sector, use foreach to show all sector with ids contained in that array

Those events won’t work. The repeats in the sub events will only be over the objects that were selected in the parent event, and not all the objects in the scene. You’ll need a

@Jump, hardcoding it in events makes it very inflexible and a pain to change. So instead of calling it a parent/umbrella Id, say call it UncoverTheseId, and make it an array or delimited string that holds all the Ids of other sectors to uncover.

When the player collides with a sector, store the values of UncoverTheseId in variable. Then in a subevent use the Pick all objects and iterate through the Ids held in the variable and select the sectors that match.

1 Like

You’re right. But with a Pick all objects before the foreach, it will cycle through all of them, and it should work.
image

1 Like

Thanks everyone for the replies! :+1: I will try to figure out how to create arrays :slightly_smiling_face:

Here! In Object Actions, under Variables.

image

1 Like

@MrMen,
@ladansedesdamnes,
Thanks a lot again) It works with array. And I figured it out, it even works like this(without arrays):

Turns out it was easy))