Kincaid's Forum Posts

  • Ah, I see. There is ceil, floor and round. And how do you round to, let's say, 2 decimal places?

  • Sorry that I hijack this topic, but when I read the reply a question came to my mind: Does Random always return an integer? If yes, what if I need a decimal?

  • Maybe I don't understand you right, but there is no animation for the swing. It's just a cone that appears for 0.1 seconds and then fades away. The cone must be the exact size and angle of the cone of view. If you have an easier solution with less lines of code feel free to tell it to me.

  • Found another way to do this but I am still curious how other people would realize this.

    This is how I did it: I created a white sprite 1 px high and I have one variable for the los range and one for the cone of view. When the player hits an enemy I start a for loop with that counts a variable up by 1 until it matches the cone of view. This for loop creates one of my sprites at the players position and with the angle set to Player.Angle+(coneOfView/2)-count. This creates sprites in the exact angle of the cone of view. I set its length to los range and this creates a cone that matches exactly my cone of view and range of sight. The sprite has the fade behavior set to 0.1 so it just flashes and quickly fades away. Maybe I have to make it higher then 1px for greater angles to minimize the gaps between the created sprites but it should work.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There is no swing_north animation. It is only one animation that rotated with the character. What I did now is spawning it with the animation sprite at the image point and setting it's angle to the movement sprites angle. Only one additional line and it works. Thanks anyway.

  • Spawning it with the animation and pinning it to the movement? Wouldn't it still always face east as long as the player doesn't turn?

  • Tried that and it works for the los part but I'm running in other problems now. Every time the player character hits an enemy I want to spawn a sprite that displays the swing of his sword. I created image points for the 4 animations (walking north, east, south and west) and spawn the swing at these image points and pin them to the character animation sprite. The problem is now that the animation sprite isn't rotating and thus the swing always faces east no matter in which direction the player is actually walking. If I spawn the swing sprite at the movement sprite it has the correct direction but it always spawns in the center of my character because there are no image points an the movement sprite. I can create 4 fake animations with a single sprite and set image points but then I have to do it blindly because I can't see my animation in the movement sprite of course.

    Only thing that comes to my mind is rotating the swing depending on the direction the character is facing. Is there a better way to spawn my swing sprite?

  • The swing is no animation. It's just a Sprite pinned to the player with 0 opacity that appears when the player swings and fades out. That is not the problem. The problem is that I want my square Sprite with straight lines to cover exactly the area where the player hits. In Photoshop you can do this with transform -> warp (not really exact though because you can't just set an angle). Imagine a square Sprite with some white and transparent lines and after the transformation it should look like the wifi symbol.

  • I have a character that swings a sword when an enemy is in his range (2D, Top Down). I realize this with the line of sight behavior. Now I want to visualize that swing. I could create a sprite with the exact angle and length as the line of sight but both can change and I want to avoid creating sprites for every possible combination. I think I read somewhere that you can transform sprites so my idea was to create a sprite with straight lines and then set the height of the sprite to the range of the line of sight and then bend it around a point at the middle of the bottom to make the lines circular depending on the cone of view. Is this possible? If yes, how? If no, what would be the best solution to visualize the swing of the sword?

  • Hm, sounds more like an answer to my other thread. This would solve the problem with rotating line of sight without rotating the animation. I'm not sure how this would help with this problem but I will try it. Thanks.

  • Hi, I have a character with a bullet behavior. You can rotate the bullet movement angle with the wasd keys to turn the character in 90 degree steps (all in top-down view). Now I need the line of sight behavior to check if an enemy is in attack range. The problem is that the line of sight always goes east. I can rotate the character and the line of sight rotates with him but this doesn't work with my animation, when you go west the character appears upside down. Is there a way to rotate the line of sight with the bullet movement angle? Or do I have to rotate my character when I want to use line of sight and I have to rotate my animation? Or is there an even better way to check if an enemy is in attack range?

  • Unfortunately I have a similar problem with my player character but this time I don't know how to resolve it.

    Like I said the player character is moving with the bullet behavior and the player is able to rotate the angle of bullet movement by 90 degrees by hitting the wasd keys. I have done this with these events:

    Keyboard on W pressed - player - set bullet angle of motion to 270 degrees

    player - set animation to "WalkNorth"

    Same for A, S and D.

    Collision check looks like this:

    Player on collision with fence OR Player is overlapping fence - player set bullet disabled

    Now I thought I can just stop the bullet movement when the player hits the fence and enable it again when the player hits one of the wasd keys. But the player character only moves a bit after rotating and then stops again. Again I think this is because he is still touching the fence. Also the player can just hit the w key when standing at the top fence and he will move a bit up every time he does which lets the player character move through the fence.

    Then I tried to set the bullet speed to 0 when the player hits the fence but now it is acting pretty strange. When I hit the nort fence the character stops moving. A and D let him rotate to west or east but he only moves i tiny bit. When the character faces north and I hit W he doesn't rotate but moves a bit to the west. When I turn south and hit the S key he moves slightly to the east. I am not possible to move the character away from the fence.

    You can download the file here: Unfortunately I have a similar problem with my player character but this time I don't know how to resolve it.

    Like I said the player character is moving with the bullet behavior and the player is able to rotate the angle of bullet movement by 90 degrees by hitting the wasd keys. I have done this with these events:

    Keyboard on W pressed - player - set bullet angle of motion to 270 degrees

    player - set animation to "WalkNorth"

    Same for A, S and D.

    Collision check looks like this:

    Player on collision with fence OR Player is overlapping fence - player set bullet disabled

    Now I thought I can just stop the bullet movement when the player hits the fence and enable it again when the player hits one of the wasd keys. But the player character only moves a bit after rotating and then stops again. Again I think this is because he is still touching the fence. Also the player can just hit the w key when standing at the top fence and he will move a bit up every time he does which lets the player character move through the fence.

    Then I tried to set the bullet speed to 0 when the player hits the fence but now it is acting pretty strange. When I hit the nort fence the character stops moving. A and D let him rotate to west or east but he only moves i tiny bit. When the character faces north and I hit W he doesn't rotate but moves a bit to the west. When I turn south and hit the S key he moves slightly to the east. I am not possible to move the character away from the fence.

    You can download the file here: https: //www. dropbox. com/s/l5d5swmgasiy8a4/Snakelike.capx?dl=0

    Edit: And again, as soon as you post your question you find the solution. Can someone explain to me why this is working now and if there is a "right" solution for this problem?

  • Still good to know that they have to be on the same layer. Didn't know that.

  • Hi, I just installed Construct 2 and did some of the beginners tutorials. Now I am trying to make a game but I don't exactly understand the solid behavior. I have my layout and all around the layout I placed sprites as a fence and gave them the solid behavior. My player character has the bullet behavior, no 8 directional movement because the player should move like in the game "snake". He is always moving forward and the player can rotate. The enemy has the bullet behavior too and should rotate randomly every few seconds. Both, player and enemy, are just going through my solid objects. I understand that you need the 8 directional movement behavior to make them react to solid objects but I need wasd-movement instead of the arrow keys. I understand too that I need to create events that check for player/enemy to collide with the fence and here it's getting tricky.

    I tried it first with the enemy: I want him to rotate 90 degrees clockwise when hitting the fence. So I made the event like this: Enemy - on collision with fence - enemy - rotate 90 degrees clockwise. This works when it first hits a wall. At the start he is in the middle of my layout walking to the right. He hits the fence and rotates 90 degrees and walks downward. But when he hits the next wall he rotates 180 going upwards, then again 180 and so on. I guess the problem is that when he hits the second wall he is exactly in the corner. He rotates 90 degrees clockwise walking along the fence but still touching it and thus rotates again in the next tick. What is the best way to avoid this? Moving the sprite a little bit away from the wall? But how do I know in which direction I should move it? Or is there a better way to let the enemy rotate when he touches the fence? There is the bounce off solids option, but I can't set the angle in which he is bouncing, right? Any other ideas maybe?

    Edit: Ha, searched for another problem and found the solution for this one. Instead of rotating the enemy by 90 degrees I can set the angle of the bullet movement to the actual angle - 90 degrees and it works.