Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: Stopping an Enemy  (Read 1111 times)

0 Members and 1 Guest are viewing this topic.
Stopping an Enemy
« on: October 10, 2008, 10:36:14 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 57
Alright the forums have probably seen this question asked a thousand times a thousand ways but here's the code

if (distance_to_object(objlink) < 90) // Or however close you want the enemy to start moving
{
    image_single = -1;
    move_towards_point(objlink.x, objlink.y, 3); // Set 3 to the speed you want the enemy to move
}
else
{
    image_single = 0;
    speed = 0; // This stops the enemy from moving
}
alarm[1] = 30; // Reset the alarm

I don't want the enemy running through solid objects as it chases Link around. I need the enemy to stop when it comes into contact with solids.

Ive looked over the help file with no luck. Thanks
Logged

Xiphirx

wat
Re: Stopping an Enemy
« Reply #1 on: October 10, 2008, 10:44:37 pm »
  • Xiphirx
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3007
Alright the forums have probably seen this question asked a thousand times a thousand ways but here's the code

if (distance_to_object(objlink) < 90) // Or however close you want the enemy to start moving
{
    image_single = -1;
    move_towards_point(objlink.x, objlink.y, 3); // Set 3 to the speed you want the enemy to move
}
else
{
    image_single = 0;
    speed = 0; // This stops the enemy from moving
}
alarm[1] = 30; // Reset the alarm

I don't want the enemy running through solid objects as it chases Link around. I need the enemy to stop when it comes into contact with solids.

Ive looked over the help file with no luck. Thanks

Well, you probably have a block object, so

Code: [Select]

if (distance_to_object(objlink) < 90) // Or however close you want the enemy to start moving
{
if !(distance_to_object(objBlock) < 1)
{
    image_single = -1;
    move_towards_point(objlink.x, objlink.y, 3); // Set 3 to the speed you want the enemy to move
}
}
else
{
    image_single = 0;
    speed = 0; // This stops the enemy from moving
}
alarm[1] = 30; // Reset the alarm

I don't know, I honestly moved away from GM, haven't used it in 2 years know :D
Logged
  • For The Swarm
Re: Stopping an Enemy
« Reply #2 on: October 10, 2008, 10:57:30 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 57
Nah that wont work. That only checks if the enemy isn't near a block before he starts moving. It doesnt stop the object while its moving. That stops it from ever moving once its near a block. Besides, I want it stop on contact with solids not blocks.

I need to somehow get a point of x and y based on the direction the enemy is moving and then plug those into a collision check I guess. I don't know either.
Logged
Re: Stopping an Enemy
« Reply #3 on: October 11, 2008, 01:53:53 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 2245
tried using move contact solid?
Logged
Re: Stopping an Enemy
« Reply #4 on: October 11, 2008, 02:11:20 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 57
I was looking at that as an option but couldn't figure out how to use it
I actually solved the problem in a gheto way by using a "bumping engine"

How does move contact solid work?
Logged
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.245 seconds with 49 queries.

anything