Another post about enemy movement

Get help using Construct 2

Post » Fri Mar 09, 2012 3:32 pm

Hi all,

First post here. I saw there are a few similar questions, but couldn't find one specific to my issue, so here it is:

Trying to make a basic platformer. The player physics are fine, and the enemy movement is fine, but when the enemy changes direction, the sprite rotates with it. So for example if it's in the correct position going right, it will rotate to be upside down when it comes back left. What I need is for it to face in the direction it is moving on the horizontal axis.

I was able to do this for the character by creating conditions such as "When right arrow pressed, mirror sprite", but I can't do that for enemies because they aren't controlled by input, so I can't apply the same conditions.

Is there some way of basically saying "when moving left, mirror image, and don't spin it around or upside down"?

Thanks in advance for any help.

Edit: Link for the capx file. As you'll be able to see, I'm just getting started and experimenting a little. The first thing that happens is the dragon spins upside down when he's supposed to be following the little guy.MonstaMunch2012-03-09 17:15:10
B
6
Posts: 22
Reputation: 751

Post » Sat Mar 10, 2012 3:17 am

Please? Anyone? It doesn't seem like it would be a hard thing to do, there must just be some simple button somewhere that I'm missing or something, surely?
B
6
Posts: 22
Reputation: 751

Post » Sat Mar 10, 2012 3:34 am

Hey Monsta,

What I do is handle the enemies animation and movement the same way as the player. Give them the relevant behaviour and then turn off "default control" in the sidebar when you have the enemy selected. Use "Simulate control" in the system commands to issue movement commands like follow the player etc.

Your dragon moves to the right at the start because you have bullet behaviour - and you first order to the dragon is after 2 seconds. IE - every 2 seconds set angle to player.

I updated your cap, made an adjustment to your dragon image, set the "set angle" property to yes and added a condition to change the image if the player is on the left or right.

http://dl.dropbox.com/u/13312935/Howisthis..capxGenkiGenga2012-03-10 05:42:15
ImageImage
B
74
S
17
G
6
Posts: 1,039
Reputation: 10,605

Post » Sat Mar 10, 2012 6:43 am

Wow, you are completely brilliant, thank you so much! I have another unrelated question but don't want to start another thread for it, so going to post here if it's ok:

http://dl.dropbox.com/u/66278067/Spacegog.capx

I used "scroll to" on the character, but I want him to be left of center like in a normal game of it's genre, instead of dead center. I'm sorry to be such a noob, but I have tried and failed.

Thanks in advance for any further help, and thanks once again for the help so far :)
B
6
Posts: 22
Reputation: 751

Post » Sat Mar 10, 2012 6:57 am

all you need for this is to add a new sprite (can be without and image) in the middle of the screen and attach the scroll to behaviour to it, instead of the player character. At the events, add the move to instruction for the new sprite and you are ready to go.
B
42
S
9
G
6
Posts: 437
Reputation: 5,626

Post » Sat Mar 10, 2012 7:03 am

Ahhh, thanks Ubivis!! And I supposed if i want the character to be able to move forward and backwards, I can make a condition for the character sprite and the "invisible sprite" to remain a set distance from each other, to maintain the effect........

It's all starting to make sense now :D Thanks again for all the help :D
B
6
Posts: 22
Reputation: 751


Return to How do I....?

Who is online

Users browsing this forum: alextro, MarkStockley and 0 guests