0 Favourites

Issue with aiming with cannon

  • 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? <img src="smileys/smiley29.gif" border="0" align="middle" />

    .capx file: dl.dropboxusercontent.com/u/11888452/cannon.capx

  • 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.

  • 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.

    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.

  • 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.

  • 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.

    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.

  • poops out the bullets

    :D

    Just change the angle to that of the cannon. E.g. Set angle -> canon.angle

  • > poops out the bullets

    :D

    Just change the angle to that of the cannon. E.g. Set angle -> canon.angle

    Sorry if I seem retarded, but I dont get it <img src="smileys/smiley17.gif" border="0" align="middle" />

    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: dl.dropboxusercontent.com/u/11888452/weirdbullets.capx

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • 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:

    <img src="http://i.imgur.com/lvRQ4eL.png" border="0" />

  • 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:

    <img src="http://i.imgur.com/lvRQ4eL.png" border="0" />

    Thats it! Got it to work.

    Thanks a ton for helping me out!

    cheers :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)