Monster AI

0 favourites
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • I want the Monster AI to move using the 8Direction Control just as the player is, but i want the monster to only start to walk towards player when in certain distance (playing movement animations face the correct direction, same as player).

    Any ideas? Basically i want the monster to walk towards player and then start to attack.

    Anyways here my .capx of the player movements , if anyone could clone the player and make that use the monster AI then i can add my monster animations in when i suss out how to actualy use Monster AI

    Download Capx

  • Are you aware of the distance() expression? That could help significantly.

  • No i wasn't , how do i simulate 8direction control on something similar to my player animations? for now i just want to clone my player and make a version that attacks the current player using Monster AI ... but i have no idea on how to simulat control towards player

    I guess having Free edition won't help me since i cant check directions like "N" or "NE" .....

  • When saving your project, select "Save as single file" to get a .capx. You have attached a .zip file of your project files.

    The .capx is basically just an archive of your project (like .zip), but we can open it directly in C2 without having to extract the archive and cluttering our folders with a bunch of project files.

    Now, on to the question:

    The easiest way is if you use the bullet behaviour on your enemies, and when your character is within a certain distance (use the distance expression like squiddster said), rotate your enemy towards your player. (use the action "Rotate towards position")

    Now, you have 8 animations for the enemy? You can compare the angle of the object to see which direction it's moving. If the angle is within 45 degrees of the angle 0 for example, the enemy is moving right. If within 45 degrees of the angle 45 degrees it's moving down-right, if within 45 degrees of the angle 90 degrees, moving down, etc..

    Edit: And btw, the free edition only limits the amount of events and the amount of layers in each layout. All the features are available except for families.

  • Okay...i got it lol, Thanks guys.

    Any examples of getting the monster to attack when it reaches player ? ofcourse the distance would be needed to stop the monster from moving into player constantly.

  • Oh I see, it's just my standard response to a zip upload. We get a few of those. <img src="smileys/smiley1.gif" border="0" align="middle" /> The .capx is a renamed .zip file, but I've seen them not open correctly on some hosts before, so I know what you mean. Most of us use dropbox so we don't have that problem.

    I think classic is pretty much the same, but I can't really answer that, never used it.

    If you use the bullet behaviour, the object will move forward along it's angle. Then you just set the angle by using the action "Set angle towards position 'Player.X, Player.Y'".

    Edit: Well, I guess you edited your post before I replied, so if anyone's wondering, that's why my post is totally unrelated to the above. <img src="smileys/smiley36.gif" border="0" align="middle" />

    To make him stop, just use the distance expression again, if he's close enough, he stops moving and attacks instead.

  • I cant seem to get the animation right without it being upside down and if i disable it from rotating it moves in only one direction ... confusing :(

    If you check out my capx ... you can see the style of my game , i need things to run smoothly on the diagonals and not strife ... so in terms using snap to grid path finding. The bullet movement is too fluent to control with the animations i have

  • Hmkay, check your bullet behaviour's properties (select object, then in the panel to the left) and set "Set angle" to "No". Then, instead of setting the angle of the sprites in the event sheet, use "Set bullet angle of motion". Input "angle(Enemy.X, Enemy.Y, Player.X, Player.Y)" as the parameter when prompted.

    Edit: Ok, never mind the above then.

  • Actually mate, it seems that method works a charm , guessing i need to check angle to play animations ??

    Thanks for your help again mate :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yeah, but you can't compare the sprite's angle like I said above, since that will always be to the right. (since we no longer change it)

    You need to use "System: Is between values" and compare 'Enemy.Bullet.AngleOfMotion'.

  • Okay, il figure out a workaround ....can you give me an example of the distance check?

    the player objects is called Player and the enemy is called Ball ...

  • Bullet_8Animation.capx (r99)

    There's probably a better, less event-heavy way of doing the animations, I'll look into it.

    Edit: Yup, much better now. Updated the file.

  • You'd lay it out like this:

    distance(Player.x, Player.y, Ball.x, Ball.y)COMPARISON (i.e greater, equal etc.) VALUE (0,1,7 etc.)

    Within the compare two values System event.

  • Thank you! i will attempt this and upload the game via FTP for testing :D

    cheers guys

  • Having problems with getting the monster using distance...Could someone look at it please?

    Download CapX

    EDIT: Sorry for double post, i thought it auto merged :O

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