Pick Object Type in Family [C2] [SOLVED]

Just started using Construct 2? Post your questions here

Post » Thu Jul 27, 2017 4:39 pm

Hey, guys or plinkie specifically!

@plinkie

Alright, here's that capx.

I'm trying to set up separate ship firing patterns.

If you'll notice in the capx, there's 4 different ship types - based on color (t1, t2, t3, t4).

I can't figure out or find on Google/Scirra how to code when a specific ship type (t1, t2...) is picked as a random instance and then link it up to the firing pattern instead of "ship_type" which obviously makes no sense in there right now.

Only coded 1 firing pattern for now, but pretty easy to change with just copy and paste.

You mentioned something that "picked instance" exists somewhere I believe, but I've never done it before so no idea how to code.

http://www.darksunpictures.com/public/R ... _MODIF.zip

@plinkie I did this publicly because the pm system is weird. Some of my messages sit in outbox for days.
Last edited by AmpedRobot on Thu Jul 27, 2017 9:24 pm, edited 1 time in total.
B
39
S
20
G
18
Posts: 265
Reputation: 12,983

Post » Thu Jul 27, 2017 7:54 pm

There you go https://www.dropbox.com/s/4u3skfkbf1612 ... .capx?dl=0

The logic can be tidied up even more with a function, it really depends on what randomness is supposed to happen.
B
47
S
17
G
82
Posts: 2,230
Reputation: 48,607

Post » Thu Jul 27, 2017 8:42 pm

Plinkie, am I wrong, but is this assigning random numbers to the ship types via "choose" and "pick", so they are only sometimes the same?

I actually wanted the same firing pattern for each different ship type consistently. So say ship type 1 or t1 would only fire green shots, ship type 2 or t2 would only fire red shots.

Is that possible?

I guess the question is; how can one compare a specific object type picked via random instance in a family?

Or is the only or better way of doing this via specific family instance variables setting everything up separately for each ship in terms of firing pattern?

I guess I was looking for a convenient shortcut if one exists.

Also, not really sure how to avoid each ship of a specific type from firing the same, some sort of random roller for the cooldown instance variable?

It gets pretty hairy 'cause I have a lot of different ship types and if you start using similar logic without one all encompassing algorithm things break down.

That's sort of the boat I am in right now. I designed a lot of different shot spawners, but it's similar logic, so they malfunction when there's multiple ship types on screen.
Last edited by AmpedRobot on Thu Jul 27, 2017 9:13 pm, edited 1 time in total.
B
39
S
20
G
18
Posts: 265
Reputation: 12,983

Post » Thu Jul 27, 2017 9:11 pm

Anything is possible, just explain exactly what you want to happen.

This one picks a ship at random, and each ship type has the same assigned fire type. https://www.dropbox.com/s/so9p2jdpzbsse ... .capx?dl=0
B
47
S
17
G
82
Posts: 2,230
Reputation: 48,607

Post » Thu Jul 27, 2017 9:16 pm

OMG, Miraab his sails unfurled!

<------You're dealing with a 40 year old brain here, so I guess it gets foggy sometimes when I have to deal with new concepts, plus so little brain space left after I had to learn all the other stuff to make this game.

This is great, thanks.
B
39
S
20
G
18
Posts: 265
Reputation: 12,983


Return to Beginner's Questions

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests