How do I do Line of Sight with bullet movement

Just started using Construct 2? Post your questions here

Post » Sun Feb 28, 2016 6:41 pm

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?
B
5
Posts: 15
Reputation: 255

Post » Mon Feb 29, 2016 5:18 am

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 :)
B
8
S
1
Posts: 46
Reputation: 544

Post » Mon Feb 29, 2016 7:32 pm

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?
B
5
Posts: 15
Reputation: 255

Post » Mon Feb 29, 2016 7:42 pm

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 :)
Last edited by Landermere on Mon Feb 29, 2016 7:46 pm, edited 1 time in total.
B
8
S
1
Posts: 46
Reputation: 544

Post » Mon Feb 29, 2016 7:45 pm

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?
B
5
Posts: 15
Reputation: 255

Post » Mon Feb 29, 2016 7:48 pm

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
B
8
S
1
Posts: 46
Reputation: 544

Post » Mon Feb 29, 2016 7:51 pm

@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.
B
8
S
1
Posts: 46
Reputation: 544

Post » Mon Feb 29, 2016 8:10 pm

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. :)
B
5
Posts: 15
Reputation: 255

Post » Mon Feb 29, 2016 8:17 pm

Sweet :) Glad you have it working :D
B
8
S
1
Posts: 46
Reputation: 544


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest