Have bullet objects adjust speed when overlapping?

Get help using Construct 2

Post » Thu Jan 19, 2017 4:28 pm

Hi!

Currently I got:

Tank2 is overlapping Tank1 > set Tank2 bullet speed to 20
<invert>Tank2 is overlapping Tank1 > set Tank2 bullet speed to 27

This actually works for me, but not for the other vehicles. These other vehicles are exactly the same way programmed:

Vehicle2 is overlapping Tank1 > set Vehicle2 bullet speed to 20
<invert>Vehicle2 is overlapping Tank1 > set Vehicle2 bullet speed to 35

I've no clue what's wrong.

I also tried adding the solid behavior to all vehicles as a workaround but that didn't do anything, vehicles just kept overlapping.

Basically, the vehicles and tanks all spawn on different y positions but I don't want them to overlap when one is going faster than the other.

I did try detecting collision. However you cannot invert collision. I just want the fastest vehicle lagging behind a slower one, to resume its speed once the slower one is destroyed.

Does anyone have any ideas?

Thanks in advance.

Regards

-R
B
13
S
7
G
4
Posts: 143
Reputation: 3,581

Post » Thu Jan 19, 2017 5:58 pm

@Rudi55

You may have to add more conditions:

Tank2 is overlapping Tank1 & is not overlapping vehicle2 > set Tank2 bullet speed to 20
B
38
S
18
G
19
Posts: 664
Reputation: 14,107

Post » Thu Jan 19, 2017 6:57 pm

Hi Jeffige,

thanks for your reply.

So I delved into adding more conditions but I'm a little confused.

For example;

Tank1 drives at a speed of 20
Vehicle1 drives at a speed of 27
Vehicle2 drives at a speed of 35

I'm confused as I'm not sure how it will unfold. I can't really grasp what conditions I need to add and how many?

Perhaps you could post a small sample code?

Thanks.
B
13
S
7
G
4
Posts: 143
Reputation: 3,581

Post » Thu Jan 19, 2017 7:43 pm

you need to use
is overlapping at offset
therefore when the faster one reach near behind the slower one you set the faster one speed to match the slow one speed at a point behind it.
Image
B
36
S
11
G
2
Posts: 312
Reputation: 3,739

Post » Thu Jan 19, 2017 9:11 pm

Hello wizdigitech.

Thanks for replying, I tried that once but didn't get the desired results. How would one program this? One sample will do.

Thanks.

P.S. There are vehicles which travel at different speeds. For example you could have a row of vehicles where the front one travels at 20, the second 30 and the third 50. Will overlap at offset work for that?

-R
B
13
S
7
G
4
Posts: 143
Reputation: 3,581

Post » Thu Jan 19, 2017 10:56 pm

@Rudi55

You're gonna have to give me some time to see what i can do.

I have a major issue when displaying a google game leaderboard and it stopping and muting all my audio. This is my last bug before publishing, so i got to get this resolved.
B
38
S
18
G
19
Posts: 664
Reputation: 14,107

Post » Fri Jan 20, 2017 11:02 pm

Ok,

so I *think* I'm grasping this.

Image

This is just a portion. I made the same group for BRDMScout, which speed is 35.

The BMP2 will slow down and adjust to T72 speed.

However, the BRDMScout adjusts to BMP2 original speed (27) so it's still overlapping the BMP2. How do I make it adjust to the 'new' speed of the BMP2?

I tried doing something with (local) variables but of course that only works if there are no copies of the same object on screen.

Any ideas?
B
13
S
7
G
4
Posts: 143
Reputation: 3,581

Post » Sat Jan 21, 2017 1:12 pm

If you are up for a more performance , lesser code, more clear ... solution. But with a plugin. Yes, then i have an idea.


https://www.dropbox.com/s/5o7zzhid8iiq1 ... .capx?dl=0


plugin: plugin-jcw-trace-raycast_t172320


I you can use families, it can be done with LOS too.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sat Jan 21, 2017 1:49 pm

Hello,

thanks for your reply!

Yes that does look a lot more simple than what I was trying to do. Your sample .capx works nicely.

Hey, I own a Construct2 license so I can use families. I did try LOS once, but I had some issues with the cone of view, and it didn't work out for me.

Since I want the cone of view to 'detect' in a 'straight line', I set the cone of view to 1 or 5 for example. Otherwise it would detect a vehicle above itself or below and I didn't want that. However it only worked for me when I set it to 360.

Do you think it can still be possible to use LOS then? LOS is something I think I can grasp. Of course, I can use your sample above, but I'm curious as to what I did wrong with the LOS.

Thanks again.

- R
B
13
S
7
G
4
Posts: 143
Reputation: 3,581

Post » Sat Jan 21, 2017 2:10 pm

@jeffige you tell me you dont have cranberry game plugin :shock: :lol: smh

did you get the tank speed to work i have a little free time now can help
Image
B
36
S
11
G
2
Posts: 312
Reputation: 3,739

Next

Return to How do I....?

Who is online

Users browsing this forum: jorgmaquoi, Yahoo [Bot] and 13 guests