Villager Simulation

For questions about using Classic.

Post » Sun Dec 14, 2008 2:23 am

I am trying to make a simulation game and the part of it I'm working on right now is the AI..

So two sprites walk randomly in the map and when by chance, they collide with each other they would pause and interact whatsoever.
The problem I have is that I don't thoroughly understand how objects and event scripting works in Construct.

The two sprite objects are of the same type. I'm having a hard time scripting using events though because I don't know how to manage who is who. For example if i want to edit a private variable of one of the sprites and not the other one. What's the easiest way of doing it.?
B
16
S
10
G
5
Posts: 255
Reputation: 3,934

Post » Sun Dec 14, 2008 5:31 am

Well, I've tried making a solution to this one, but I'm afraid I failed :P

I can make a whole village of people that walk around on their own, but I can't make them interact. I know there's a way to do it with some clever family picking, but the method eludes me. Perhaps someone else can have a go?
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sun Dec 14, 2008 7:47 am

My first approach would be to use detectors on the four sides of the villager, and if they want to move, it has to check if the detector is over a obstacle (house, rock, person, ect.)

This thread explains it better:
viewtopic.php?f=3&t=2036&p=15268&hilit=grid+movement#p15268

I dunno, maybe it'll work with that method?
B
13
S
3
G
5
Posts: 286
Reputation: 3,193

Post » Sun Dec 14, 2008 10:20 am

Well I guess the moving itself of the sprites isn't the problem midnight.

But couldn't you like have some interaction detector together with the sprite/hitbox. Then on creation set a private variable of the detector to the UID of the sprite. Now if that detector overlaps another one of the same type of sprite which has a different UID than stored in the variable => interaction.

Or maybe I'm missing something important just my first thought on it, didn't try it myself yet. Maybe you could go more into detail what you're exactly doing eventwise right now hero_bash.
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Sun Dec 14, 2008 4:44 pm

Yeha I know that moving it isn't the problem, I was just suggesting using detectors on all four sides to check is movement was legal. That's a good idea though setting a UID for each of the sprites.
I think there's something about this question that confuses us all lol
B
13
S
3
G
5
Posts: 286
Reputation: 3,193


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests