create a movement area

0 favourites
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Ok, perhapps im looking at this the wrong way, and im making things more complicated than they should be

    basically, i have a map, on that map seen from above, i have an unit, when i click on that unit, i want a circle to appear below it, that circle represents the movement area.

    that is done

    What i cant do is set the 8 directions movement on the unit to stop within the boundaries of the circle that appeared below.

    I have this to make the circle appear below the unit

    <img src="" border="0" />

    any ideas on how to make the unit move only whithin the circle?

    thank you

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I managed to make it move this way

    <img src="" border="0" />

    But i need to make it stop when it reached the edge.

    i tryed this,

    <img src="" border="0" />

    But even making the stop area transparent, it allways detects as overlaping, so it starts adn stops moving at the same time, i tryed collision instead of overlapping, but what happens is that i leave the circle, still moving, and when i try to reenter, it colides and stops moving. so it detects the collision from outside in but not from inside out

    is there any way to set a condition as "is no longer overlaping" ?

  • Please, blonduck, provide me the CAPX and I will fill it with a sample code for you, because it's too much longer to write on a post, and there I can comment the code.

  • here it is

    thank you for the help

  • Since your range is circular, you could limit the hero's movement based on the distance between the hero and the movement area. If the distance between the 2 sprites is greater than the range, set the hero's position according to its maximum range and angle compared to the movement area. It sounds more complicated than it is, you just need some basic trig. You can do it all in a single event. Here's a demo and capx with the method using a single event, and the method broken out for explanatory purposes:



    An added benefit is that there is no collision detection to take up processing power. I hope this helps.

  • I could not open the Capx file, could it be restricted to the full version?

  • blonduck

    Making a sprite transparent doesn't stop it from being overlapped, the issue is that your movement and non-movement zones overlap each other. Why don't you just say when not overlapping the movement zone? DO an overlap condition, then right click on it and choose invert. So then you have one for moving in the zone, and stopping when you are no longer in it. Or even better, do an else.

    Character Overlapping MovementZone > 8 Direction Movement Enabled

    Else > 8 Direction Movemenet Disabled

  • interesting, didnt know about tha tpossibility, ill go check it out

  • Whatever version of C2 are you using? The capx was created using release 124. If you're using a previous release, it won't open. I don't think the file being created using the full version would affect your ability to open it. Regardless, there isn't much to the code. Here's a screenshot of the event sheet:

    <img src="" border="0" />

  • yea, i had release 119, uim upgrading right now :D

    thank you so much

  • I'll be at home in +1 hour, so, I do the sample for you too, and you can have two references! that's great!!! =P

  • mmm it seems like i still need to get my grip arrown this

    i have some problems

    if i use the following, get an empty screen, i dont even see my hero, that is otherwise placed at arownd 50,50

    <img src="" border="0" />

    so i thought, ok that is making my hero disappear somehow so i tryed this

    <img src="" border="0" />

    but with this, i do see my here, but he can freely move, and when i click on him he spawns the Origin and the movement area, but he can still move freely.

    so i tryed this third one.

    <img src="" border="0" />

    but again i do not see my hero?

    any idea on what am I doing wrong?

  • awsome telle. I apreciate it, i am really trying to learn this software, i have severall ideas that i woudl like to implement.

  • The issue is that when you already have a movementArea created off screen. Because you haven't tied the hero to a specific movement areas, he gets tied to the first one that was created (the one that's off screen). That's why he seems to disappear. Add a "Movement Area Destroy" Action at the start of layout, and a instance variable on the hero to say whether he can move or not. This worked fine:

    <img src="" border="0" />

  • awsome, thank you, i was wondering if objects outside the area where affected by variables, i guess this aleso answers my question :D

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