playMaker

Author Topic: 2D Platformer AI  (Read 2164 times)

ShaquitaChicken

  • Playmaker Newbie
  • *
  • Posts: 6
2D Platformer AI
« on: February 25, 2016, 06:17:38 PM »
Relatively new to Playmaker but I get all the actions just need to get more familiar with it.

So for my AI, which im not over-complicating (stickin with triggers/ray casts) im wanting to transition my old AI which is manually programmed (shoot on sight, damage player on collide, etc...) to playmaker, which i already used an FSM on the AI and added a distamce checker (using floats) and a move towards so it goes to player...


Now I want to abuse Playmaker so im just going to redo the whole AI completely but i need help first :(

AI Scenario:
I would like the the AI tier im making now to be capable to run and shoot. I dont want the AI to merge with the player which happens when you use move towards (but i could make it move towards a collider around the player)


My questions:
-How would i base the animation on velocity of AI so if it stops running, it goes idle state animation?
-What actions are good for having the AI shoot projectile prefabs based on raycasts if it hits player.
-How could i make the AI not merge with the player but simply just stand still a certain distance from the player

Zeldag

  • Full Member
  • ***
  • Posts: 198
Re: 2D Platformer AI
« Reply #1 on: February 26, 2016, 08:30:05 AM »
Hi,

Just a quick try at your questions:

1. (using animator) Make transition from run to idle dependant on a float, when float is less than 0.1 transition to idle (and back again when above 0.1). In playmaker use a get 'velocity2d' action and a 'set animator float' action to get the object's velocity and set it to the animator.

2. There is a 'raycast' action, which can save many things, such as which object it hit. There is a 'compare game object by tag' action that can check if it is the player. Then of course the 'create object' action to spawn the prefab.

3. Many ways i think... One of them: use a 'get distance' action (get distance to player into a float). Then 'compare float' action to check when the distance is low enough to stop (also I think that if youre already using a raycast, you can probably use the distance it can store instead of a 'get distance' action).

Also you may have these already but for my answers (or anyone else's i bet) you will need some action packs:

https://hutonggames.fogbugz.com/?W1150 (2d action pack)

https://hutonggames.fogbugz.com/?W1031
(mecanim action pack)

Best of luck with it, hope some of my ramble helped. Let us know how it goes.