How do I make a sprite move on click on platform like map

Get help using Construct 2

Post » Mon Mar 06, 2017 10:16 am

Hello! I'm new to Construct 2 using it on a friend's computer before I buy so I make sure Construct is ok for what I want to do. I'm trying to get something to work but we didn't find any solution:
I'd like to make a 'This War Of Mine' like movement for my units. They are on a 2D map and can move only horizontally. So I'm trying to make them go wherever the user clicks but I'm getting different issues with the different options I've tried. The best results I could get by now are with Custom Movement behavior and accelerating toward position but nothing works properly :

X=0 and Y=Mouse.Y makes the sprite move left when I click on its left but it still goes left (walking backwards) when I click on its right(oO).
X=Mouse.X and Y=0 makes it oddly fly more or less pointing towards mouse position.

I guess Pathfinding isn't really an option here as there's no solid to stop it from going up or down.
And two smaller problems I haven't really been digging into for now are:
-I need the sprite to point toward this direction (mirror if I click behind its back; Do I need to create variables to constantly check its position, cut the screen in two parts according to this position and make it defined wheter I click on the back part or the front part?)
-Once it started accelerating toward a position it doesn't stop (It looks like there are other questions like this on the forum so I'll probably check it if my first problem is solved and you don't wanna take the time to explain here :) )

Thank you very much for taking the time to read this.
B
3
Posts: 5
Reputation: 185

Post » Mon Mar 06, 2017 11:36 am

Not sure I can help without seeing a CAPX but if you only want the players to move horizontally then you only need to change the X coordinate which is left and right on the screen.

You would use the Y coordinate of the player and only change the X coordinate to the Mouse X coordinate.

Set Player Position Player.Y Mouse.X

That way the player always stays at the same Y coordinate and only moves on the X coordinate.

You should go ahead and download the free C2 version so you have your own copy to practice with.
Banned User
B
23
S
6
G
58
Posts: 1,229
Reputation: 34,540

Post » Mon Mar 06, 2017 2:03 pm

I dont see Set Player Position and Player.Y isn't an object. Plus there will be many units so this is not really the playr
B
3
Posts: 5
Reputation: 185

Post » Mon Mar 06, 2017 2:10 pm

VKZ1 wrote:I dont see Set Player Position and Player.Y isn't an object. Plus there will be many units so this is not really the playr



Player refers to your object sprite.

If you are not moving sprites what are you moving?

Without a CAPX to look at I can't really help you.
Banned User
B
23
S
6
G
58
Posts: 1,229
Reputation: 34,540

Post » Mon Mar 06, 2017 2:59 pm

Message: VKZ1 can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
WTF i think I edtied my last post too much it dissapeared :/ So here is the link to the capX : http://s000.tinyupload.com/index.php?file_id=45581180834559851597
You will se he can't go to the left because left is greater -or equal- to Mouse.X
Is there a way to reset it when he reaches Mouse.X or just another way to make him stop ?
And if you have one more minute I'd also like to know how to make him rotate (mirror would be more accurate) when he goes backwards (so he faces the direction h's going to even though his moonwalking skills look amazing). But that will be for when we manage to make him go backwards of course
B
3
Posts: 5
Reputation: 185

Post » Mon Mar 06, 2017 3:05 pm

Instead of using Sprite X > Mouse.X use Sprite X = Mouse.X

That way it only stops when it reaches that mouse pointer.

You will need to set the speed back where you want it when it does not = Mouse.X

On Sprite X NOT EQUAL Mouse.X set speed whatever speed you want.

That should fix it.
Banned User
B
23
S
6
G
58
Posts: 1,229
Reputation: 34,540

Post » Mon Mar 06, 2017 3:08 pm

With SpriteX=Mouse.X it doesn't stop :/ It seems to want to stop for a second but I guess the acceleration keeps it moving.
I tried both stop and set speed to 0 but it doesn't stop
B
3
Posts: 5
Reputation: 185


Return to How do I....?

Who is online

Users browsing this forum: alextro, Ryan Kocourek and 1 guest