Problems with multiple objects shooting
I'm making a game. Suffice it to say, I'm having minor difficulties.
I have ObjectA as the base object. You control it using the racecar movement (right now, set to arrow keys, changing it to WSAD movement). There's a targeting reticule that uses the mouse (thus, fire1 is left click).
ObjectB, ObjectC, ObjectD are all set on ObjectA. They don't move, but turn (basically, turrets). They always face the reticule, which as I said, is controlled by the mouse.
Each turret has an individual counter to determine how far along the reload cycle it is (thus, you could hammer off three shots, then wait a few seconds before you next three, or time them out).
Problem: All three shoot when the player presses fire. I have a fourth counter to determine which one fires. At 0, B shoots. 1 is C, 2 is D. Each event sets the counter higher. Whenever the counter is set to 3, it resets to 0. But all three still fire, and I have yet to figure out a way to do this.
Also, is there any way to make the turrets turrets turn slower? Remember, you are using the mouse to move, and the base object is always moving (and can turn as well).
Help!
Re: Problems with multiple objects shooting
You'll have to identify which turret you want to fire by picking it either by fixed value or alterable variable. For alterable variable, you'll first need to spread a value across all turrets for that base - and if you have many bases, it will get more complicated still.
If you go to the old forum archive (link at base of page), MMF 1.5 File Archive, and do a search for 'turret', you'll find loads of related examples. This one in particular:
http://www.clickteam.com/CTforum/showthr...amp;Main=214394
Re: Problems with multiple objects shooting
Thanks, I'll see what I can do with what you gave me, Sarah.
The counter was supposed to be the alterable variable. I even tried it with the base having the variable, but that didn't work either. I also tried to put a "Every x milliseconds" in it, but that made the shooting sometimes not happen (try clicking once every 5 or 10 milliseconds, doesn't work. Even still, it shot ALL the turrets).
My goal was to make a game where you fought against multiple enemies - each with one to three turrets. I just don't see a possible way to do it right now. I'll work on it a bit.
Re: Problems with multiple objects shooting
You could use the "select random <your object>" condition. This will then pick one of your turrets and let it shoot.
About the rotating - it really depends on how you do the rotating. If you use the 32 MMF directions then it's more tricky. If you use 360 degree, by making use of the set angle action to rotate it, you can rotate by single degrees (use the advanced direction object for angle calculations).
But this way it will be harder to make them shoot bullets in the right direction.
Re: Problems with multiple objects shooting
the problem is, i want it to shoot from the individual turrets in sequence, not at random.
so, turretA fires, then turretB, then turretC, on each subsquent mouse click, it selects which turret to fire automatically. and i can't figure out how to do it. i've tried using a counter, using a variable inside the base unit. and i'm pretty sure using a variable to set which turret is active isn't going to work very well, either.
i'm confused as to how i ever did it before. i had a platform game, when you hit a button, it froze movement for one character, and would let you move a different one. it was pretty much like "the lost vikings" only robots, and also the fact that each was different.
for the scrolling, i want each turret to always want to look towards the reticule. but i don't want them always looking towards it.
basically, it's a battleship. i want the battleship's turrets to look towards the reticule, however, i want them to turn slowly towards it, not always moving as fast as they can.
any suggestions?
Re: Problems with multiple objects shooting
If it was me, I'd do all this as prerendered graphics. So I'd have an animation with turret1 rotating then shooting, then another with turret 2 doing the same etc.
Re: Problems with multiple objects shooting
that's possible, however, not for the game i'm making.
the base can rotate. the base is one object, and it moves about the screen.
each turret is a seperate object. as in, each one has a set behavior, seperated in the event editor. i could modify that, but i'd rather have them seperate. it should, in theory work, but it's not.
and having each turret rotate + fire, that means that the animations would be messed up. as far as the rotating slow, it's not a big deal. i just want each turret to fire independently right now.