...rgiht, I know this is a noobish question, but I really want to know how to do a shutgun with a top view game. More precise, the player looks towards mouse pointer, I want to shoot 5 bullets in more or less random direction towards the mouse.
You've got a few choices here. You can make 5 different bullet objects, each one should have a couple frames of animation, now off set them with the hotspot, meaning make the bullet appear to move to the left or the right by setting the hotspot off one or two from the previous frame. Now, make sure you loop the last frame of animation, otherwise the bullets will move really strangly. Rotate the bullets (the handy little circular arrow rotate button) For your firing command, just use a shoot at command. Make a couple of these and you get a kind of shot gun effect.
I shall bury my head in the sand and ignore all the TGF users, 'cause it's hard to make a decent movement with it. But you can't really make a shotgun unless you use 360 degree movement - I mean, the pellets don't spread out as much as two TGF directions :/
I have a much more complicated way of doing it, but my code is at home. I'll throw up a little example and post it here later, you will need fastloops though.
Very quick fix for this: Create five of your "bullet" objects and set their directions to Dir("Player") + ((random(5) - 2)). That should randomise the bullet spread between -2 and +2 directions away from where the player is facing.
That does use TGF directions, though, which as said above may be a little too spread out.
If your using a 360 degree bullet engine then you've got alot of choices on how to do it.
This is pretty much assuming that you've already set up 360 degree projectile movement for your shotgun pellets.
- Player pressed fire button
Run "Shotgun" FastLoop 5 times
- "Shotgun" loops is running
Create Pellet 0,0 at Players action spot...or wherever
Set Value A of Pellet to (360 degree conversion of where players aiming) + 10 - random(21)
Set X of Pellet to X("Pellet") + 3 - random(7)
Set Y of Pellet to Y("Pellet") + 3 - random(7)
This is assuming a few things.
Firstly, you have a value in 360 degrees for the direction your player is aiming.
Secondly, that Value A of Pellet is the direction in degrees.
And that you have the whole 360 degree engine setup.
Basically you can play around with the numbers here. I've made the pellets have a random inaccuracy of + or - 10 degrees off where the player is aiming. And an initial spread of + or - 3 pixels from where the pellets were originally created.
I could make an example if you don't fully understand.
MUGGUS
Come and annoy me more at
www.muggus69.tk STOUT ANGER!!!
So, what should I do. I dont have a 360 engin, and I dont want it. I tried Wong`s example, and it was a little to spread out - as he said him self. So what should I do If I have MMF and want to do 5 shotgun bullets shoting towards an object?