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

0 favourites
  • 7 posts
From the Asset Store
Two types of minimap: "full map" and "player is the center" (square map and radial map)
  • 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.

  • 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.

  • 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

  • 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.

  • WTF i think I edtied my last post too much it dissapeared :/ So here is the link to the capX : s000.tinyupload.com/index.php

    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

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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

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