Problem with line of sight combined with Set Angle Towards

Get help using Construct 2

Post » Sat Sep 17, 2016 12:51 pm

Hello, I seem to have a problem using the line of sight behavior for a "boss". I've been trying to set up different behaviors using bullet, platformer and various different ones. Most of the time it just flips upside down and then goes to the "opposite" direction from me. I searched around the forum and some people said I had to flip the animation to be default towards the right, but that made the exact same problem.

For the second thing if you know how to solve this, how do I have the "boss" switch animations depending on where I am? I guess it's something with detecting Player.X and Y.
B
7
Posts: 26
Reputation: 332

Post » Sat Sep 17, 2016 1:24 pm

What kind of functionality do you want for the boss? I can assume you are trying to make the boss face and follow the player but not sure if that's what you are trying to do. I've been able to set up this kind of functionality when the boss is a bullet or using 8-direction and have no issue with animation direction.

Again, it depends on what exactly you want to happen. You could have the boss switch animations based on if it does or does not have line of sight of the player if that's what you're trying to do, if it's specific areas on screen you could detect if player is overlapping a specific checkpoint, is a certain distance away from the boss etc, if you are switching the boss' animation based on stages of the boss then you could set up a variable for what stage of the fight it's at and switch the animations that way if for instance it's a boss that is being damaged and you want to change how badly damaged it looks.
B
47
S
17
G
82
Posts: 2,230
Reputation: 48,607

Post » Sat Sep 17, 2016 2:04 pm

Basically I want it to follow me to hit me with its hitboxes (basically like mario hitboxes) so I have to jump to damage it (I already know how to code that).

I want the boss to try get on me while I jump from platform to platform and my guess using pathfinding I can make it so it follows me on platforms too but the main problem is to make it follow me. I'll try the animation suggestion if I get this to work.

The problem with the upside down is caused by the "Set Angle Toward Player.X and Player.Y". It basically rotates (I checked every option including set angle on bullet behavior".
Is there a different code you know about to make it follow my actual player placement?
B
7
Posts: 26
Reputation: 332

Post » Sat Sep 17, 2016 2:12 pm

I was assuming top down game, which is where set angle toward, pathfinding, 8-direction are useful. If it's a side-scrolling left-to-right mario platformer I don't think you need to make use of set angle toward player, you could give the boss platform behaviour and have it simulate movements left to right towards the player object and if the boss X > set animation facing right, if x < set animation facing left that kind of thing. Instead of platform behaviour you could also just move toward the player at the given angle. You could do this in 3 events, move boss forward a number of pixels (at given angle), if boss.x > player.x set angle 180, if boss.x < player.x set angle 0 in its basic form. I mention platform behaviour on the boss because if you are wanting to simulate it jumping and chasing you then this behaviour will be useful.
B
47
S
17
G
82
Posts: 2,230
Reputation: 48,607

Post » Sat Sep 17, 2016 2:46 pm

What other towards the player object is there? Since you mentioned platform behavior to move towards the player at given angle.

I tried custom movements and it does what I want it to but the deacceleration is not instant and it does not want to change animations.

To change the boss direction I just do "X > Player.X" and "X < Player.X" to move left or right.

Sorry if there is anything I am missing, I am happy enough that you are willing to support.
B
7
Posts: 26
Reputation: 332

Post » Sat Sep 17, 2016 2:53 pm

I just don't like set angle toward player in side scrolling platformers because it targets the origin image point and starts rotating the object toward that image point. I prefer to set a defined angle for the boss then move it forwards at that angle. I am using the boss move forward a number of pixels action, it will move at the current set angle so usually 180 or 0 (left/right). Instead of this move forward however, you can use platform behaviour to simulate left,right presses which also works, either of those two options will be fine. I can send you a capx example if you want but it is just 3 events and you're already using 2 of them!
B
47
S
17
G
82
Posts: 2,230
Reputation: 48,607

Post » Sat Sep 17, 2016 3:42 pm

This is what you are after in its basic form right? https://dl.dropboxusercontent.com/u/495 ... ollow.capx
B
47
S
17
G
82
Posts: 2,230
Reputation: 48,607

Post » Sat Sep 17, 2016 4:16 pm

That actually was the one I was looking for! It works fine now, the only problem persist is when he is moving towards me, its animation is upside down. When I move to the other side he has the correct animation, but is floating. Here are some pictures:
http://i.imgur.com/G888lOi.png
http://i.imgur.com/QiIZYoz.png
B
7
Posts: 26
Reputation: 332

Post » Sat Sep 17, 2016 4:25 pm

Looks like the angle of the boss is set to 270 (or -90) for some reason. You'll have to check your logic for that.
B
47
S
17
G
82
Posts: 2,230
Reputation: 48,607

Post » Sat Sep 17, 2016 4:48 pm

I did 360 instead of 180 and it is placed correctly but now it is moving to the right same as the other number "0". My guess it is because the angle is not set up correctly with the sprite animation.
B
7
Posts: 26
Reputation: 332

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 19 guests