How do I make multiple instances move to different places?

Get help using Construct 2

Post » Tue Jul 14, 2015 7:31 am

I need my instances to patrol two points that are spawned by them when a timer goes off.
Eg: Instance created, Instance is static, Timer goes off, Instance spawns two points(A and B)close to it, and then it begins moving between the two.

My problem occurs when another Instance is created, it spawns two points of it's own but just follows the old points created by Instance 1, thus colliding with Instance 1, and basically just patrolling Instance 1's route.

I've also tried a method I saw in the forums, where using a bullet behavior the Instances move randomly through a number of points.
I'm not looking for that type of behavior, as the instances overlap each other frequently, and the points are not really random.

Can I get some help?

Thanks.
B
4
S
1
G
1
Posts: 33
Reputation: 714

Post » Tue Jul 14, 2015 2:45 pm

Well, tbh it's a bit difficult to tell. I'm inclined to think your objects are confused about which objects they patrol between, but without more information it's just guesswork.
My tutorial through development blog is at http://myconstruct2dev.blogspot.co.uk/
B
12
S
3
Posts: 221
Reputation: 1,328

Post » Tue Jul 14, 2015 3:10 pm

You need to make sure each spawned Point knows who it's parent is. Add an instance variable for the ParentUID, and set it to the parent's UID. Then just do a "Pick by comparison" of the Points with the appropriate Parent ID and perform your patrol code.
ImageImageImage
B
71
S
22
G
248
Posts: 3,757
Reputation: 138,065

Post » Tue Jul 14, 2015 4:29 pm

I don't whink you need some kind of special behavior to do it... I did something similar in our very first game: http://lucho.octetostudios.com/
Maybe you will not understand the instructions because it's in spanish, but the idea of police patrolling is what I think you are looking for.

Basically what we did was that every police has an instance variable called "name" (police01, police02, etc). The patrol between points (A and B) have an instance variable called "forPoliceName" (police01, police02, etc). So, this way the patrolling points belongs only to one police instance. Then you patrolling method has to evaluate if the patrolling point belongs to the police you are moving or not and then move to it or another if the condition matches or not.

In that game, we have several police instances and every police has several patrolling points and it works perfect. Even the patrolling path changes to you if you get caught entering to a house. The police starts following you for a limited period of time and then it gets back to its original patrolling path. Take a look at it a tell me if it helps :)
Lead developer at Octeto Studios
Visit our portfolio at: http://www.octetostudios.com/ :)
Facebook || Twitter || Youtube
B
37
S
7
G
5
Posts: 217
Reputation: 5,613

Post » Wed Jul 15, 2015 2:45 pm

blackhornet wrote:You need to make sure each spawned Point knows who it's parent is. Add an instance variable for the ParentUID, and set it to the parent's UID. Then just do a "Pick by comparison" of the Points with the appropriate Parent ID and perform your patrol code.


I tried your method, and it worked for one of the instances(it followed the waypoint created by it), but the other instance that was created later just froze. I debugged the game later and found out that the latter instance didn't spawn a waypoint with its parent ID, so it just stood there. :(

GamerGon wrote:I don't whink you need some kind of special behavior to do it... I did something similar in our very first game: http://lucho.octetostudios.com/
Maybe you will not understand the instructions because it's in spanish, but the idea of police patrolling is what I think you are looking for.

Basically what we did was that every police has an instance variable called "name" (police01, police02, etc). The patrol between points (A and B) have an instance variable called "forPoliceName" (police01, police02, etc). So, this way the patrolling points belongs only to one police instance. Then you patrolling method has to evaluate if the patrolling point belongs to the police you are moving or not and then move to it or another if the condition matches or not.

In that game, we have several police instances and every police has several patrolling points and it works perfect. Even the patrolling path changes to you if you get caught entering to a house. The police starts following you for a limited period of time and then it gets back to its original patrolling path. Take a look at it a tell me if it helps :)


This is sort of what I am looking for.
Could you perhaps explain further in detail?

Thank you.
B
4
S
1
G
1
Posts: 33
Reputation: 714

Post » Wed Jul 15, 2015 3:16 pm

yodason45 wrote:
GamerGon wrote:I don't whink you need some kind of special behavior to do it... I did something similar in our very first game: http://lucho.octetostudios.com/
Maybe you will not understand the instructions because it's in spanish, but the idea of police patrolling is what I think you are looking for.

Basically what we did was that every police has an instance variable called "name" (police01, police02, etc). The patrol between points (A and B) have an instance variable called "forPoliceName" (police01, police02, etc). So, this way the patrolling points belongs only to one police instance. Then you patrolling method has to evaluate if the patrolling point belongs to the police you are moving or not and then move to it or another if the condition matches or not.

In that game, we have several police instances and every police has several patrolling points and it works perfect. Even the patrolling path changes to you if you get caught entering to a house. The police starts following you for a limited period of time and then it gets back to its original patrolling path. Take a look at it a tell me if it helps :)


This is sort of what I am looking for.
Could you perhaps explain further in detail?

Thank you.


Give me a couple of days to me find the C2 project to remember all the details and explain a little more or maybe post and image of a piece "of code" ... it was a long time ago...
Lead developer at Octeto Studios
Visit our portfolio at: http://www.octetostudios.com/ :)
Facebook || Twitter || Youtube
B
37
S
7
G
5
Posts: 217
Reputation: 5,613

Post » Wed Jul 15, 2015 4:53 pm

ImageImageImage
B
71
S
22
G
248
Posts: 3,757
Reputation: 138,065

Post » Thu Jul 16, 2015 6:37 am

blackhornet wrote:http://www.blackhornettechnologies.com/Construct2Stuff/PatrolExample.capx
(You need LiteTween).


Thank you. This helped alot.
Although while trying to reconstruct it, I ran into some problems.

First off, upon creation 'Sprite' starts moving on it own, without the waypoints. After the waypoint creation it moves along well though.
This is a bit problematic because sometimes the 'Sprite' moves all the way off screen. :(

Secondly, I did not understand the first two lines of events and thus while recreating it, I made them up myself.
I'm thinking that is the reason I'm having the first problem.
Could you explain the first two lines of events for me?

Image

I understood the 'at start of layout: destroy instances' event, but I did not understand the sub event.
Could you please explain it to me?

Thank you.
B
4
S
1
G
1
Posts: 33
Reputation: 714

Post » Thu Jul 16, 2015 12:31 pm

The sub-event is just placing three sprites randomly on the screen, and starting their individual timers with a random timeout.
ImageImageImage
B
71
S
22
G
248
Posts: 3,757
Reputation: 138,065


Return to How do I....?

Who is online

Users browsing this forum: Christmas, Yahoo [Bot], yippiez and 27 guests