theruler333's Recent Forum Activity

  • The pathfinding behavior is very CPU intensive. In your code, you are using a loop inside which you are finding a path. This starts the process of finding a path repeatedly and you will eventually run out of processing power to complete the task so, it is no wonder the game is crashing. Have you read through the documentation and tutorials on pathfinding? If you had, you would see this is not how to use the behavior.

    There is a really good tutorial on combining 2 behaviors to get an enemy to chase the player:Read through it. You may find an easy way to do what your are trying to do. Also, make sure to read all the documentation on the pathfinding behavior in the manual and check out a couple other tutorials.

    I hope that gets you what you need and good luck with your project.

    Thanks for the information. I'm going to do more in-depth research into the pathfinding behaviour. One question, I thought about the processing intensity for the CPU, that's why I added the wait action but it doesn't work, can you shed some light on that?

  • now.. I understand.. I think..

    you want to kill just monster you clicked on, even if bullet will fly through hordes of other monsters to reach your aim? we need to kill just clicked one and save others, yes?

    ok, let's do something like that:

    create global var ClickedMonsterID first

    I don't know you want to use mouse or touch, but let's use touch, it can simulate mouse by default

    Touch -> On tap monster
         ClickedMonsterID = monster.IID (or UID, no big difference for our example I think)
         <launch bullet with your parameters>
    
    On bullet collision with monster
         If monster.IID (or UID) = ClickedMonsterID
              bullet.Destroy
              monster.Destroy[/code:38a1wj3u]
    of course, it can slow down game performance because of too many collision checks.
    
    Another way is better on my look but not so good because of one moment..
    So.. take all your monsters and toggle off [i]Collision[/i] property (to Disable value).
    And then code will be much easier:
    
    [code:38a1wj3u]Touch -> On tap monster
         monster - Set collisions enabled = Enabled
         <bullet fire>
    
    On bullet collision with monster
         bullet.Destroy
         monster.Destroy[/code:38a1wj3u]
    So, there will be just one monster who can collide with bullet.
    I don't know will it work or not, but you may try it. But you can use it only if you never need constant check of any other monster collisions (with obstacles for example).
    
    Try both and say your opinion.
    

    Thanks man! I used aspects of your first suggestion to get it working. I can't use the second one even though is less performance impacting as the monsters need collisions enabled at all times

  • How do I use the Pathfinding feature to follow a moving object. So far I have this code but it just crashes my game when I click a monster outside of the basic_attack_radius variable:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • emm.. when you check collision between monster and bullet, monster will be picked!

    On bullet collision with monster
    monster - Destroy[/code:gtz6hdlu]
    no need to pick this monster specially
    
    must work
    

    I think my explanation was a bit dodgy. I have got:

    On bullet collision with monster
    bullet - Destroy[/code:gtz6hdlu]
    
    But because I have multiple monster sprites running around, when the bullet is fired it is meant to destroy itself when it hits the monster that was clicked, however if another monster sprite is in the line of fire the bullet will be destroyed at that monster. I want the bullet to be destroyed when it hits the one I clicked on.
  • so you need to understand what bullet is for what monster

    you can pick needed monster by his IID (for example)

    every bullet - some var instance, ex. MonsterID

    after shot make Bullet.MonsterID = needed Monster.IID

    then in cycle for every bullet you need to pick monster with IID = bullet.MonsterID and then Bullet -- set angle towards -- monster.X, monster.Y

    Thanks I've fixed the problem. I didn't need the bullet ID as only one bullet will be on the screen at one time. But do you know how I can differentiate the monster thats colliding with the bullet?, as I've got multiple monster sprites on the screen.

  • sKill both 12 and 13 sub-events.

    Make an event (NOT sub-event) Bullet -- On collision with... Monster --> Bullet.Destroy

    Make an event (NOT sub-event) System -- Every tick --> Bullet -- Set angle Towards Monster.X, Monster.Y

    Why Bullet spawns Bullet? I think Player must spawn Bullet.

    Mmm.. try it. I think it will be more correct.

    This is a good fix if I only had one monster. The reason why I had it in sub-events is because it kept the same UID for the monster that was clicked on. Now your way is good but i need it to lock on to the monster that was clicked, how do I go about doing that?

  • I'm trying to make the bullet auto lock on and hit the target. I've tried using a while loop with the bullet behavior enabled and constantly setting the angle of the bullet towards the monster, until the bullet comes into collision with the monster, but as soon as I click on the monster my game crashes.

    I've attached a picture of my problem as I cant use the

    tag

  • Ok thank you so much!

  • I have an event where when the player uses the right mouse click, my sprite has the bullet behavior enabled and rotates 360 degrees to the mouse x and y position. Then it sets a global variable called goalX to the mouse x position. Then in a separate event where if goalX = my sprite.X it disables the bullet behavior on the player but this doesn't work. Any help on getting this to work would be greatly appreciated!

theruler333's avatar

theruler333

Member since 8 Jan, 2015

None one is following theruler333 yet!

Trophy Case

  • 9-Year Club
  • Email Verified

Progress

10/44
How to earn trophies