Issue with aiming with cannon

Get help using Construct 2

Post » Mon Apr 15, 2013 5:31 pm

Hello! I have encountered yet another problem while making my pretty simple game. Usually I manage to solve the problems I get, but Ive been stuck now for a hour or so messing around in the event sheet, behaviors etc, so it would be nice if I could get some help here.

As the title describes, I simply cant make the cannon aim the way I want it to. I've done the first tutorial on the website, where you make the player(gun) aim where the mouse is, but that does not work with what I am trying to do now.

To start with, I'd like the cannon to be stuck to the cannon-holder when it rotates. I thought I made it work by placing the image-point on the lower end on the cannon, but when I do that the bullets comes from the same spot, so it doesnt look right. If I place the image-point at where the bullets should come from (as we learn in the first tutorial), then the rotating looks weird. (you'll understand better once you take a look on the game and the .capx file).

Then I'd also like the cannon to face the other side of the mouse instead of looking towards it. So, if my mouse is on the right side of the cannon, the cannon will aim left. If the mouse is on the left side, the cannon aims right. If the mouse is under the cannon, the cannon aims upwards and so on. And the last thing is that, I want it to do that only when I click on the cannon (and/or on the cannon-holder) and hold the button down. But I cant find that option under the conditions in mouse.

Any idea on how I can make it work?

.capx file: https://dl.dropboxusercontent.com/u/11888452/cannon.capx DV72013-04-15 17:34:14
B
4
Posts: 15
Reputation: 580

Post » Mon Apr 15, 2013 5:35 pm

Place an image point at the end of the cannon and make the canon holder a separate unmovable sprite. Gee, in this forum, the questions are either this, either a person who can't use global variables either a pile of mathematics bullsh*t I can't read! This is a real mess.
HARMLESS SIGNATURE THAT IS VIEWED BY OTHERS AS OFFENSIVE AND CONTROVERSIAL
B
14
S
3
G
3
Posts: 356
Reputation: 4,362

Post » Mon Apr 15, 2013 5:45 pm

[QUOTE=fassFlash] Place an image point at the end of the cannon and make the canon holder a separate unmovable sprite. Gee, in this forum, the questions are either this, either a person who can't use global variables either a pile of mathematics bullsh*t I can't read! This is a real mess.[/QUOTE]

The cannon-holder is already a separate sprite.

And Ive already tried with placing the image point at the end of the cannon, where the bullets should come out from, but when I do that, the cannon wont be stuck to the holder, which is what I cant get to work, along with the aiming.
B
4
Posts: 15
Reputation: 580

Post » Mon Apr 15, 2013 5:59 pm

Try using 2 image points, one closer to the cannon holder and the other one that poops out the bullets. The closer to the cannon holder point is the origin and is rotating to the mouse.
HARMLESS SIGNATURE THAT IS VIEWED BY OTHERS AS OFFENSIVE AND CONTROVERSIAL
B
14
S
3
G
3
Posts: 356
Reputation: 4,362

Post » Mon Apr 15, 2013 6:16 pm

[QUOTE=fassFlash] Try using 2 image points, one closer to the cannon holder and the other one that poops out the bullets. The closer to the cannon holder point is the origin and is rotating to the mouse.[/QUOTE]

Ok, that part is working now. Thanks a ton!

Now I just need to figure out how to make the aim-thingy work. Do you happen to have any idea on how to make that work? Ive changed my mind a little, I'll have the mouse on "every tick" instead of holding the button down, it is easier that way, but I still dont know how to make the cannon to face the opposite direction of the mouse...

EDIT!: Oh, after a second, I noticed that the bullets arent traveling where they are supposed to (where the cannon aims), but to the side :(
EDIT2: aha, managed to solve that part.DV72013-04-15 18:25:37
B
4
Posts: 15
Reputation: 580

Post » Mon Apr 15, 2013 6:25 pm

[QUOTE=fassFlash]poops out the bullets[/QUOTE]

:D

Just change the angle to that of the cannon. E.g. Set angle -> canon.angle
Moderator
B
72
S
13
G
11
Posts: 900
Reputation: 11,783

Post » Mon Apr 15, 2013 8:32 pm

[QUOTE=thehen] [QUOTE=fassFlash]poops out the bullets[/QUOTE]

:D

Just change the angle to that of the cannon. E.g. Set angle -> canon.angle[/QUOTE]

Sorry if I seem retarded, but I dont get it

Anyhow, I've solved the aim-to-the-opposite-direction-problem but could you explain (or anyone else that would like to help me out a little) why the bullets are going to the side, and how I can make them go normally?

(hold the left mouse button down to rotate the cannon, press space to shoot)

.capx: https://dl.dropboxusercontent.com/u/11888452/weirdbullets.capx
B
4
Posts: 15
Reputation: 580

Post » Mon Apr 15, 2013 8:52 pm

In C2, a 0 degree angle is to the right, and rotates clockwise. Your cannon sprite points up at 0 degrees, and that's causing the confusing. Try rotating it 90 degrees to the right:

B
44
S
13
G
7
Posts: 338
Reputation: 10,379

Post » Mon Apr 15, 2013 9:03 pm

[QUOTE=zatyka] In C2, a 0 degree angle is to the right, and rotates clockwise. Your cannon sprite points up at 0 degrees, and that's causing the confusing. Try rotating it 90 degrees to the right:

[/QUOTE]

Thats it! Got it to work.
Thanks a ton for helping me out!

cheers :)
B
4
Posts: 15
Reputation: 580


Return to How do I....?

Who is online

Users browsing this forum: Mohicano and 25 guests