How do I do Line of Sight with bullet movement

0 favourites
  • 9 posts
From the Asset Store
solution for games like "fruit ninja" and drawing applications
  • Hi, I have a character with a bullet behavior. You can rotate the bullet movement angle with the wasd keys to turn the character in 90 degree steps (all in top-down view). Now I need the line of sight behavior to check if an enemy is in attack range. The problem is that the line of sight always goes east. I can rotate the character and the line of sight rotates with him but this doesn't work with my animation, when you go west the character appears upside down. Is there a way to rotate the line of sight with the bullet movement angle? Or do I have to rotate my character when I want to use line of sight and I have to rotate my animation? Or is there an even better way to check if an enemy is in attack range?

  • If you separate your player into 2 different sprites; 1 controlling movement and 1 controlling animation, you could use these to check line of sight without having animations that change

  • Tried that and it works for the los part but I'm running in other problems now. Every time the player character hits an enemy I want to spawn a sprite that displays the swing of his sword. I created image points for the 4 animations (walking north, east, south and west) and spawn the swing at these image points and pin them to the character animation sprite. The problem is now that the animation sprite isn't rotating and thus the swing always faces east no matter in which direction the player is actually walking. If I spawn the swing sprite at the movement sprite it has the correct direction but it always spawns in the center of my character because there are no image points an the movement sprite. I can create 4 fake animations with a single sprite and set image points but then I have to do it blindly because I can't see my animation in the movement sprite of course.

    Only thing that comes to my mind is rotating the swing depending on the direction the character is facing. Is there a better way to spawn my swing sprite?

  • You could just pin it to the movement

    You can have 1 origin point on the right hand side of the movement sprite.

    When the movement sprite turns towards an angle, that image will also move to that side.

    if you pin the swing sprite to the player on start of layout and make it invisible, when you turn the player movement it should also turn so just set it to visible

  • Spawning it with the animation and pinning it to the movement? Wouldn't it still always face east as long as the player doesn't turn?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm suggesting that you do not spawn the animation, merely make it visible when you swing your sword

    When you change the angle of motion of the player (original angle is 0 which will be east) the whole sprite changes angle so to will the imagepoint

  • Kincaid

    OH! my bad....I guess I missed out the part where the swing animation is not facing the correct way lmao. Oops.

    So for the animation of the swing, I would link it with your movement inputs from the player so

    when player pressed "W" play "swing_north" animation.

  • There is no swing_north animation. It is only one animation that rotated with the character. What I did now is spawning it with the animation sprite at the image point and setting it's angle to the movement sprites angle. Only one additional line and it works. Thanks anyway.

  • Sweet

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