Bullets In Gamesalad!?
Eminem
Member Posts: 667
I have a actor and i want it to release / spawn an actor (Bullet) anyway i can do this ? and the way i want this is when the user taps on the enemy the bullet will then goto the actor that is pressed
any clue how i can do this?
Many Thanks!
any clue how i can do this?
Many Thanks!
Comments
http://gamesalad.com/game/play/24892
It forms the basis for my next game
Thing is, that I've found it works great for 90% of the time. Which is obviously a problem. It needs to work ALL the time.
Still, unless someone like Tshirt or FMG come up with something better (hint hint) this is probably your best bet.
Cheers,
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
Let's start with the easier part. Spawning a bullet:
create a bullet actor.
Put a move behavior in this actor. Set the speed to whatever and the direction to 0 to actor.
Create a shooter actor
For now try this - Rule - when spacebar is pressed
spawn bullet
0 to actor.
Assuming your image for the shooter actor is facing to the right (as it should be in GS) the bullet will come out of the front of the actor no matter which way you have rotated it. So this is good to use with a joystick or d pad or tilt controls that cause your shooter to rotate.
Now, to have the bullet go directly to an actor that has been selected could be trickier. You will need to have a game attribute for the X and the Y of the enemy actor. An easier way of doing this would be to have one boolean attribute called game.fire.
Rule (in the enemy)
when touch is pressed change game.fire to true (1)
in shooter
Rule when game.fire is true
spawn bullet
in bullet
move - for the direction you will need to use VectorToAngle(game.touch.1.X-sef.positionX,game.touch.1Y-self.positionY)
speed to whatever you want
(you could try move to instead in the bullet and just put the two touch coordinates in for x and y but I have found "move to" to be buggy.
good luck!
http://gamesalad.com/game/play/76515
Makes me think of this
CHALLENGE! I couldn't resist a chance to out do the mighty TSB!
Nice try, sunshine, but if you click multiple times the bullets all go to one place!
CHALLENGE!!!!
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
Let me get me tap shoes on and see what I can do...
Right???
Yep - what happens is you tap on the screen - and the bullet goes to that point and is then destroyed.
Unless it hits something along the way - in which case it hits the object and the bullet is destroyed then.
Like I said, it works 90% of the time. I *was* going to send CodeMonkey a video of a crying sheep with my gameproject.
Can you spare him the guilt?
QS
Edit: And what I mean by 90% of the time is you can play through a level just fine, and everything works great when you play through it a few times.
*THEN* - sometimes what happens is that the first bullet doesn't go to where you tap it, but off by quite a bit. Say you tapped to the right, it would go straight up for example.
Not good!
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
It uses no game level variables and can spawn multiple bullets at once and they all act independent of each other.
Sorry I've been gone so long, I had to move houses and I've been feeling anti-computer for a while. I'm back!
Did I win the prize?
http://gamesalad.com/game/play/76525
check it out.
Both work, though your one, Scitunes, has some 'strays' in it that won't stop
Also, orbz used particles for trails, which is what my game does. But that's just icing, right?
I'll have a look at them and see what I can do.
You both get a free copy of the game regardless. I'm not sure you'll like it. But hey, it's free!
And considering t-shirt got me started down this road, the same applies for him, obviously.
Mail me at quantumsheepinfo at googlemail dot com and let me know if you want your nickname here, or your real name, in the credits
Thank you both! I'll test out how these solutions work on a device - which is the clincher!
Cheers!
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
Orbz, can you explain the time < target distance/maxspeed
how does this stop the bullet?
I understand magnitude but don't see what the division problem is all about.
It's based on the concept that a bullet travels in a strait line for a duration, that duration = distance over speed. The angle is calculated on touch and then the bullet just travels in a strait line for a given duration then stops. Simple.
@QS, yes the trails are icing
So we can use some basic algebra to say:
T = D / R
So we say the bullet moves for a given duration T, that T is calculated as the distance to move D, divided by the velocity that the object is moving at, it's speed, R.
When that duration T is up, it stops. This simple formula only works for linear motion, calculus is needed for acceleration and such.
@QS - don't use mine! Orbz's is way better!
But! Thank you - I'm trying to just copy these actors over and I'll see how it works!
Again, thanks to you and Bill (!) - you've helped two people with, er, two examples...
I'll let you know how I get on!
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
You guys both get a free copy of my game when it's done too! Oct 15th!
PS, anyone want to help with art? I have no extra cash yet but I'll put your name in the credz. Let me know in a private email if you are interested. joel a t orbz d o t com
I couldn't get it to work straight away because, you know, it's almost 5am here and I'm stupid!
Orbz very kindly did some email troubleshooting, and now it works.
PERFECTLY!!!
Thanks Orbz!
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io