Auto search an object in layout?

For questions about using Classic.

Post » Sun Nov 22, 2009 1:38 pm

How would an object with custom movement as its behavior be able to auto search an object that is found in the same layout? Like if an NPC would automatically know where the bathroom is if it needed to have its poo poo time. Or maybe it will randomly circle the layout until it finds the object its looking for.

I'm guessing Line of Sight might help with this....
B
10
S
5
G
8
Posts: 203
Reputation: 4,395

Post » Sun Nov 22, 2009 2:09 pm

Well, that is a more complex topic, I am afraid. Depends on what you want to achieve, but you'll have to implement basic routines such as go-to.

Simplest solution would be to use a waypoint system, create one waypoint in each room and corridor, visit each and remember the visited until the bathroom is found, then remember the waypoint (and quickly calculate the shortest path and use that in the future).

Have fun!
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Sun Nov 22, 2009 4:07 pm

I see. Well, I have not mingled with waypoints before. Guess this is a start. Anyway, what values are placed in waypoints? X and Y? I'm not in my PC right now so I can't check it out for myself. And can waypoint be included in a hash table?

I mean what if an NPC goes to remember a waypoint, and the player saves the game and quits. Will the waypoint still be there when the player plays again?

Oh wait, I have a follow up question. What will be better?
1. Make a huge map(4000x2000?) in errr mspaint and import it in Construct and just put colission boxes in places where its suppose to be solid.
2. Make the same map in mspaint but break it down into small objects and import it one by one in Construct and then rebuild the map there.

So which one? I have been doing number 1 by the way.
B
10
S
5
G
8
Posts: 203
Reputation: 4,395

Post » Sun Nov 22, 2009 6:11 pm

Waypoints should act as nodes, you'd have to store coordinates as well as names of waypoints it is directly connected to. So when you look for a path, you can solve through each waypoint's neighbours, iterate until you find the goal, then use the shortest path.

As for your question, multiple map pieces are better than one large map. The 4000x2000 would use up 4096x4096 pixels in video memory, which is 16 MB. If you break it down into 1024x1024 pieces, you can use eight of them, each is a megabyte, thus you save 8 MB memory. Moreover, only one of them would be rendered at a time (if you use 1024x768 resolution), so it would be faster to load and render.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 9 guests