Make bullets shoot in right direction?

Get help using Construct 2

Post » Sun Jan 19, 2014 1:03 pm

Hi all,

I'm new to Construct - had a hunt through forums and how tos but not found an answer to this - apologies if it's obvious. Feels like it should be...?

I've started making a shooter with Zelda 4-direction style movement, i.e. not quite top down so have sprites/animations for each direction. So not using mouse or mouse angles etc for firing.

Player shoots when space bar pressed. The bullets always go right and can't find a way of changing that. Tried to make it so bullet angle was set by what direction key was pressed (as that dictates which way player is facing) but then if you change direction after firing so does your bullet.

Anyone know how I could solve this?

Thanks all
B
5
Posts: 19
Reputation: 323

Post » Sun Jan 19, 2014 1:57 pm

I guess you are using something like

on space-bar pressed create bullet at player position ?

if so try changing it to

on space bar pressed player spawn new sprite bullet.

(spawn will create your new bullet at the players position and at the same angle as the player)

I am also assuming you are using the bullet behaviour on the bullet ?

Have a read through the beginners tutorials - nearly everything is covered there.
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,892

Post » Sun Jan 19, 2014 6:03 pm

Using on space bar spawn new sprite.

Because it's 4 direction and not truly top down 8 direction, like the Ghost Shooter in beginners guide, there's no player angle to use. It's more like an old school Zelda in terms of movement. (I tried to link to a URL to give an example but not allowed to yet.) Basically when you press a direction a new sprite/animation is loaded that corresponds to that direction. Not one sprite that rotates like in the Beginners Guide.
B
5
Posts: 19
Reputation: 323

Post » Sun Jan 19, 2014 6:18 pm

You can test what animation is currently playing and set bullet angle to that animation
if "walk left" is playing set bullet anggle to 0
if "walk down"... set to 90

or you can name your animations to 0 - for walk left, 90 - for walk down... and then set bullet angle to animation name

there's quite many ways to go with what you want to do.

Best way is to put your capx file here and ask to look at it and help you with events you already have.
ImageImageImageImage
B
158
S
67
G
43
Posts: 2,603
Reputation: 36,003

Post » Sun Jan 19, 2014 6:19 pm

Okay, so lets say your animation frames for the directions are: 0 - right, 1 - down, 2 - left, 3 - up

right after the bullet is created add an event for the bullet:

Set angle of motion (or bullet angle? not sure here) = 90 * Sprite.AnimationFrame

This way the bullet will go:

Frame 0 -> 90 * 0 = 0, right direction of movement
Frame 1 -> 90 * 1 = 90, down direction of movement
Frame 2 -> 90 * 2 = 180, left direction of movement
Frame 3 -> 90 * 3 = 270, up direction of movement

Hope that helps :)
Construct Classic - Examples Kit Dropbox is a pile of trash and if you need my old files PM me! :)
B
127
S
43
G
18
Posts: 2,240
Reputation: 20,592

Post » Sun Jan 19, 2014 6:35 pm

Thanks guys - this is all very helpful. I'm trying to use a tutorial I found on Direction-Based Sprite Animation to try and set the animations up properly in a way which records the angle of the player but it asks me to "add sub-event" and I can't find that in the menus.

I right click on an event as the tutorial says but it's not there.
B
5
Posts: 19
Reputation: 323

Post » Sun Jan 19, 2014 6:36 pm

Found it - menus at the top. Sorry.
B
5
Posts: 19
Reputation: 323

Post » Sun Feb 02, 2014 7:59 pm

Can you provide a link to that tutorial you mentioned? That would be helpful to me too.
B
3
Posts: 4
Reputation: 208


Return to How do I....?

Who is online

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