I Wanna Community

AI Question

0 Members and 1 Guest are viewing this topic.

Offline N3ON

  • 3
  • ...
  • OS:
  • Windows 10 Windows 10
  • Browser:
  • Chrome 55.0.2883.87 Chrome 55.0.2883.87
  • Playstyle: Keyboard
AI Question
« on: December 18, 2016, 02:21:09 PM »
Okay, before i begin, i wanna say that i understand a fair amount of programming, when it comes to game maker: studio, with around 332 hours in the program, but I have no idea how i would get this to work.

Basically, i want to make an object that moves towards the player, but instead of instantly changing it's direction to always move towards the player, i want the object to overshoot if the player dodges, and turn around to try again, like sonic from IWBTB, or this example i found:


As I said, I have no idea where to start with something like this, so any help will be appreciated.

Offline Nogard

  • 25
  • OS:
  • Windows 8.1/Server 2012 Windows 8.1/Server 2012
  • Browser:
  • Chrome 55.0.2883.87 Chrome 55.0.2883.87
    • Twitch
  • Playstyle: Keyboard
Re: AI Question
« Reply #1 on: December 18, 2016, 02:47:57 PM »
You could use the built in gravity_direction to have the desired behaviour.

Set the gravity in the create event, and in the step event have the line:

Code: [Select]
with(objPlayer)
  other.gravity_direction=point_direction(other.x,other.y,x,y);

So that the acceleration of your object is always pointing towards the player.
If you don't want said object to get too far away from the player I suggest also putting a cap on its speed.
Twitch channel: http://www.twitch.tv/nogard_
My not very used twitter account: https://twitter.com/Nogard__
Clear list: https://goo.gl/rnoqiz

Offline N3ON

  • 3
  • ...
  • OS:
  • Windows 10 Windows 10
  • Browser:
  • Chrome 55.0.2883.87 Chrome 55.0.2883.87
  • Playstyle: Keyboard
Re: AI Question
« Reply #2 on: December 18, 2016, 03:12:46 PM »
You could use the built in gravity_direction to have the desired behaviour.

Set the gravity in the create event, and in the step event have the line:

Code: [Select]
with(objPlayer)
  other.gravity_direction=point_direction(other.x,other.y,x,y);

So that the acceleration of your object is always pointing towards the player.
If you don't want said object to get too far away from the player I suggest also putting a cap on its speed.

This worked surprisingly well! Thanks!  :atkHappy: