Nabu's Forum Posts

  • Not so easy ^^

    RayKi is right, if you want your npcs look at the player, when you're talking to them, you have to check and compare the position of your player and your npc. Depending on your game, the npc will change animation (4 directions, or 8) or make a rotation (so rotate toward position or set angle toward position). You have to implement a way to know when to trigger the effect and change the npc state.

    Pseudo logic :

    • when talk key pressed (or any other way)
    • check and compare player's position and npcs position to get the nearest one
    • pick it and make it change state and animation to start diaglogue

    For the npc stay in an area, I assume you already have a behavior or them to wander (you talked about make them stop wandering). There are several ways to do this. You can simply set a zone with an invisible sprite stretched to the desired dimension. When sprite are overlapping that zone, they get wander position inside it, or don't move, if they aren't overlapping that zone, they tend to reach it. For performance reason, you can check overlapping every 0.1 or 0.2 seconds, and not every tick as it's not necessary or this.

  • Hi,

    You have the option to change it at runtime. Chek for Z-Order => Move to top/bottom of layer, Move to layer (you specify), and move to Object which let you choose in front or behind.

  • Hello,

    I tried to implement a multiple Shadow Lights system with Ashley's advices from these two topics :

    https://www.scirra.com/forum/concerns-with-the-light-shadow-so-far_t106486

    https://www.scirra.com/forum/light-and-shadows-drawing_t106379

    When I set the Shadow Light opacity to less than 100, you can see that the Shadow Light cast multiple polygons from a Tilemap object with Shadow Caster behavior, that overlap and so cumulate alpha (surely to avoid having a big concave polygon). This make a multiple lights system (with Alpha threshold as Ashley mentionned) impossible. I made a little project to illustrate the problem : https://www.dropbox.com/s/2d5gmgwxes129ua/MultipeLightsShadows.capx?dl=0 Just mouse click to apply or remove alpha threshold.

    I manage to get close to the desired result by setting each Shadow Light at 100% opacity on a dedicated layer with 50% opacity, to get the "wrong" shadow into a flatten one. The superposition of the two layers give a good result but then I don't kwow how to apply a alpha threshold effect on the sum of the two layers. Here is the second example :

    https://www.dropbox.com/s/xwj876hv3hbhoh6/MultipeLightsShadows2.capx?dl=0

    Any idea ? I find no soluton.

  • Thanks a lot for your time and the feedback !

  • Sorry, finally this probably a bug, so I posted it here :

  • Problem Description

    Sprite with pathfinder won't find path in Chrome and NW.js if some musics are played

    Attach a Capx

    https://www.dropbox.com/s/wre9txx3t7zfhq9/Test.capx?dl=0

    Description of Capx

    Layout with a Tilemap. Spawn player with right click, make it find path with left click.

    Steps to Reproduce Bug

    • Step 1 : Make a layout with tilemap, and another layout with player sprite. Make a spawn function to create player at mouse coordinates. Make a music plays at first layout start. (not all music make the bug appears, only the first one in the given .capx)
    • Step 2 : Spawn player (right click). Left click to make the it find a path, at a location hidden with obstacle. Observed Result Sprite with Pathfinding behavior won't find path if there's an obstacle between his position and destination. Else it works. If the player sprite is already in the first layout nd not spawned via a function, and the path obstacle is added at ayout start, problem won't appear. Expected Result Sprite find path. Affected Browsers
      • Chrome: (YES)
      • NW.js: (YES)
      • FireFox: (NO)
      • Internet Explorer: (NO)

    Operating System and Service Pack

    Windows 7 SP1

    Construct 2 Version ID

    Release 200 64bit

  • I did some tests, trying to reproduce the problem but failed. The only thing I discovered is it works under Firefox, but no under Chrome or NodeWebkit. I would like to make a desktop game, so export to NW.js...

    The special things in my project are :

    • two tilemaps (only one is given as obstacle to pathfinder)
    • tilemaps randomly generated (obstacle given to pathfinder after map is generated)

    Don't know if it's the cause.

    Any idea ?

  • Hey,

    I've never done that but just thought about it. You can retrieve the waypoints from a given path and use the physics to reach them. Once unit arrive (don't know if there's an ever built in condition, or just compare unit position and path's current node) go to the next. The physic movement implementation should be the difficult part, because you will have to tweak forces (in construct itself or from a movement plugin) for you unit move nicely towards a direction to a given point.

  • Hello,

    I'm having issues with the Pathfinding behavior. First I'm sorry to have nothing to show because I can't reproduce the problem in a small simple project and mine is way too large for asking other people to work on it or find a mistake in it.

    The problem I have is that sprites with Pathfinding behavior achieve to find path if the path is a straight line, but not if it needs to avoid obstacles. I have already verified the map (tilemap) and checked the pathfinding obstacle map and everything is ok. The sprites are stuck in "calculating" path. The behavior is set to custom and I add the tilemap at sprite creation, after tilemap is created. Changing to solid do not solve the problem.

    I tested everything and tried to reproduce the error without success. I'm lost.

    Anyone has ever encounter the same ?

  • Ok, thank yo all for the tip. Grateful

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hello,

    The problem you have is probably related to SCOPE, object picking and object creation. The functions have a scope, itself, and almost everything outside is ignored. So when you call the "spawn_ship" function, it works as expected. But when you call after that the function "set_FactionRed", the latest created SHIP_small instance is out of scope. Also, when you create an object, you can just set up its variables in the first following event scope. When you press F a second time, your function "set_FactionRed" will get al last the first instance of the SHIP_small object type, due to the fact that objects are accessible the next tick they are created (except modifying them just in the same event scope after system => create object). That's why operations in the "spawn_ship" function works correctly but not operations from the "set_FactionRed" function.

    I hope it's not confusing...

    So what you can do is putting everything in the first function (quick but not very practice), or put the "returnValue" property of your functions with the UID of the nely created object (Object.UID, not ID as it's not reliable) pass it (Function.ReturnValue) to the functions that are following. In these functions, you have to pick the instance by UID first (so in a function, it's with Function.Param(something)) and do the modifications you want.

    Not confusing ?

    I'm not very good in english for explanations...

  • Hey, here's a little example with spikes that goes underground endlessly. I set up three types of spikes, just changing the "wave" property of the Sine behavior. Note that the "sawtooth" wave equation is probably what you want. Just check the collision with the sprite and players/entities and do as you like. You can add randomized values to the Sine behavior if you want it to be less predictable. The "width/height" parameters of the "movement" property could be good too as it scales the objects. The magnitude is how large is the movement, in pixels or percents.

    You can see that the spikes are on the "behind" layer, with "tilemap" layer in front.

    This is a simple way to do that. You can also have custom movement by writing your own and changing state and position of the spike object every tick or less. For example you can add a "active" bolean variable to the sprite and set it true only while it's rising from the ground, setting false while retracting. When you're checking for collisions you can also check for if the spike is active or not. If it is, hurt the player, if not, the player can walk upon it.

    Hope this helps if you haven't already find a solution.

    https://www.dropbox.com/s/9xusp6gx0y00e0u/spikes.capx?dl=0

    Cheers

    Nabu

  • Hey,

    Just wanted to know if there's a way to display the pathfinding obstacle map. It would be useful when debugging a project.

    Thx

  • I managed to correctly draw the Tilemap with your tip R0J0hound. It works pretty well and allows the rest of a game development. The probleme is mainly with Particles and Spritefonts that are a little bit harder to move, paste and move back. That's why I wanted to simply move the viewport, but it doesn't work well.

    What's exactly the problem with the project I attached ? Why the viewport get stuck in the last moved position ?

  • Hi,

    I have a problem with the function "Scroll To Position". I'm trying to set up a split screen game with the Paster plugin. The fact is that some object (tilemaps, particles, spritefonts) are not displayed if not on screen. So I have to move these objects every tick to the player position to paste them on the canvas and move them back to their position. As an alternative I tried to just move the viewport to player position, to make everything near him onscreen. But this didn't work as expected.

    So every tick I scroll the viewport to the player position. If there's one player, it works well. But with two players and two canvas I have to scroll the viewport twice in the same tick. The view port seems to be stuck in the last scroll position as the special objects that require to be on screen are not displayed if player 2 if too far from player 1.

    I made a little project for example. You can seen that the tilemap is not always paste onto the first screen (player1) unless player 2 is close to player 1.

    https://www.dropbox.com/s/jrmxp8yim7h7rpn/splitscreenScroll.capx?dl=0

    So is it possible to scroll twice in the same tick ? Or is there something to do to achieve this ? Cause I find moving all objects to fixed viewport and moving them back sometimes hard to implement with big project and moving the viewport would be more simple.