Jump to content


Photo

Coordinates zone


  • Please log in to reply
14 replies to this topic

#1 AJFaas

AJFaas

    GMC Member

  • New Member
  • 8 posts
  • Version:GM8

Posted 23 May 2012 - 02:55 PM

Hello guys,

I would like to know if there is a command, to put in a wider range of coordinates. That it kind of becomes a zone, that you enter.

I mean like: If there is a object between position X:1 to X:300, walk right.

I want to know it for enemy AI that, if you get to close, he walks towards you.

Thanks in advance.
  • 0

#2 Zoltan Kriven

Zoltan Kriven

    GMC Member

  • GMC Member
  • 342 posts
  • Version:GM8.1

Posted 23 May 2012 - 03:20 PM

Hello guys,

I would like to know if there is a command, to put in a wider range of coordinates. That it kind of becomes a zone, that you enter.

I mean like: If there is a object between position X:1 to X:300, walk right.

I want to know it for enemy AI that, if you get to close, he walks towards you.

Thanks in advance.

Yes but it is not just 1 command.
if x >= 1//if you are between 1
{
if x <= 300 //and 300
{ //movement code here  
}
}

Or you could use in your enemy code:
step event:
code box:
if distance_to_point(player_obj.x,player_obj.y) <= 300
{//movement code here
}

I would use the 2nd one because the first one is just refering to a location on the screen where the second one actually refers to the distance between the player and the enemy.

Please let me know if this was helpful.

Edited by Zoltan Kriven, 23 May 2012 - 03:22 PM.

  • 0

#3 AJFaas

AJFaas

    GMC Member

  • New Member
  • 8 posts
  • Version:GM8

Posted 23 May 2012 - 04:12 PM


Hello guys,

I would like to know if there is a command, to put in a wider range of coordinates. That it kind of becomes a zone, that you enter.

I mean like: If there is a object between position X:1 to X:300, walk right.

I want to know it for enemy AI that, if you get to close, he walks towards you.

Thanks in advance.

Yes but it is not just 1 command.
if x >= 1//if you are between 1
{
if x <= 300 //and 300
{ //movement code here  
}
}

Or you could use in your enemy code:
step event:
code box:
if distance_to_point(player_obj.x,player_obj.y) <= 300
{//movement code here
}

I would use the 2nd one because the first one is just refering to a location on the screen where the second one actually refers to the distance between the player and the enemy.

Please let me know if this was helpful.


Hey, i forgot to mention that i use drag and drop. I really dont understand code.

If you could tell me how to excecute it in the Check Object, That would help alot.

You can use variables there so it should be possible.
  • 0

#4 Zoltan Kriven

Zoltan Kriven

    GMC Member

  • GMC Member
  • 342 posts
  • Version:GM8.1

Posted 23 May 2012 - 04:22 PM



Hello guys,

I would like to know if there is a command, to put in a wider range of coordinates. That it kind of becomes a zone, that you enter.

I mean like: If there is a object between position X:1 to X:300, walk right.

I want to know it for enemy AI that, if you get to close, he walks towards you.

Thanks in advance.

Yes but it is not just 1 command.
if x >= 1//if you are between 1
{
if x <= 300 //and 300
{ //movement code here  
}
}

Or you could use in your enemy code:
step event:
code box:
if distance_to_point(player_obj.x,player_obj.y) <= 300
{//movement code here
}

I would use the 2nd one because the first one is just refering to a location on the screen where the second one actually refers to the distance between the player and the enemy.

Please let me know if this was helpful.


Hey, i forgot to mention that i use drag and drop. I really dont understand code.

If you could tell me how to excecute it in the Check Object, That would help alot.

You can use variables there so it should be possible.


in the step event for your enemy put the test expresion, it's in the control tab, copy and paste this: distance_to_point(player_obj.x,player_obj.y) <= 300
then go to the move tab and put the move to point block, in it put
x: player_obj.x
y: player_obj.y
speed: whatever you want the number to be.

Edited by Zoltan Kriven, 23 May 2012 - 04:25 PM.

  • 0

#5 AJFaas

AJFaas

    GMC Member

  • New Member
  • 8 posts
  • Version:GM8

Posted 23 May 2012 - 04:41 PM




Hello guys,

I would like to know if there is a command, to put in a wider range of coordinates. That it kind of becomes a zone, that you enter.

I mean like: If there is a object between position X:1 to X:300, walk right.

I want to know it for enemy AI that, if you get to close, he walks towards you.

Thanks in advance.

Yes but it is not just 1 command.
if x >= 1//if you are between 1
{
if x <= 300 //and 300
{ //movement code here  
}
}

Or you could use in your enemy code:
step event:
code box:
if distance_to_point(player_obj.x,player_obj.y) <= 300
{//movement code here
}

I would use the 2nd one because the first one is just refering to a location on the screen where the second one actually refers to the distance between the player and the enemy.

Please let me know if this was helpful.


Hey, i forgot to mention that i use drag and drop. I really dont understand code.

If you could tell me how to excecute it in the Check Object, That would help alot.

You can use variables there so it should be possible.


in the step event for your enemy put the test expresion, it's in the control tab, copy and paste this: distance_to_point(player_obj.x,player_obj.y) <= 300
then go to the move tab and put the move to point block, in it put
x: player_obj.x
y: player_obj.y
speed: whatever you want the number to be.


It works!

Thanks for your knowledge, and time, friend.
  • 0

#6 Zoltan Kriven

Zoltan Kriven

    GMC Member

  • GMC Member
  • 342 posts
  • Version:GM8.1

Posted 23 May 2012 - 04:46 PM

[/quote]

It works!

Thanks for your knowledge, and time, friend.
[/quote]

Anytime.
  • 0

#7 AJFaas

AJFaas

    GMC Member

  • New Member
  • 8 posts
  • Version:GM8

Posted 23 May 2012 - 05:37 PM

Hey,

A problem showed up.

Any way to let them react to specific directions?

As it is now the enemy moves to you no matter what direction you are.

Is there a way to make it direction specific? x, -x, y, -y.

If youre < 300.x move right
If youre < 300.y move down
etc something in that way.
  • 0

#8 Zoltan Kriven

Zoltan Kriven

    GMC Member

  • GMC Member
  • 342 posts
  • Version:GM8.1

Posted 23 May 2012 - 05:44 PM

Hey,

A problem showed up.

Any way to let them react to specific directions?

As it is now the enemy moves to you no matter what direction you are.

Is there a way to make it direction specific? x, -x, y, -y.

If youre < 300.x move right
If youre < 300.y move down
etc something in that way.

if you give me a minute I could probably write a code for that, but I don't know how to do it using drag and drop. I know that sound sweird.
  • 0

#9 @Alex@

@Alex@

    Retired GMC Reviewer

  • Reviewer
  • 3146 posts
  • Version:Unknown

Posted 23 May 2012 - 05:51 PM

I have no idea what Drag and Drop commands there are but if there is one that acts like Collision_line you could use that.
  • 0

#10 Zoltan Kriven

Zoltan Kriven

    GMC Member

  • GMC Member
  • 342 posts
  • Version:GM8.1

Posted 23 May 2012 - 06:00 PM

I have no idea what Drag and Drop commands there are but if there is one that acts like Collision_line you could use that.


try this in the step event: test expresion just as before: distance_to_point(player_obj.x,player_obj.y) <= 300
then put check var if y is less than player.y set the move direction after that to up with whatever speed

then the same test expression followed by:
check var if y is larger than player.y set the move direction to down after that to whatever speed

the same test expresion
check var if x is less than player.x set the move direction left to whatever speed

the same test expresion
check var if x is larger than player.x set the move direction to right to whatever speed.

Did that help, it should all be drag and drop.

Just to clarify your step event should look something like this:
:GM060:
:GM073:
:GM002:
:GM060:
:GM073:
:GM002:
:GM060:
:GM073:
:GM002:
:GM060:
:GM073:
:GM002:

Edited by Zoltan Kriven, 23 May 2012 - 06:05 PM.

  • 0

#11 AJFaas

AJFaas

    GMC Member

  • New Member
  • 8 posts
  • Version:GM8

Posted 23 May 2012 - 06:35 PM


I have no idea what Drag and Drop commands there are but if there is one that acts like Collision_line you could use that.


try this in the step event: test expresion just as before: distance_to_point(player_obj.x,player_obj.y) <= 300
then put check var if y is less than player.y set the move direction after that to up with whatever speed

then the same test expression followed by:
check var if y is larger than player.y set the move direction to down after that to whatever speed

the same test expresion
check var if x is less than player.x set the move direction left to whatever speed

the same test expresion
check var if x is larger than player.x set the move direction to right to whatever speed.

Did that help, it should all be drag and drop.

Just to clarify your step event should look something like this:
:GM060:
:GM073:
:GM002:
:GM060:
:GM073:
:GM002:
:GM060:
:GM073:
:GM002:
:GM060:
:GM073:
:GM002:


The movement didnt work smoothly, thats why i did jump to position instead of move. And it worked perfect.

Thanks again, you've been a great help to me. :thumbsup:
  • 0

#12 Zoltan Kriven

Zoltan Kriven

    GMC Member

  • GMC Member
  • 342 posts
  • Version:GM8.1

Posted 23 May 2012 - 06:38 PM



I have no idea what Drag and Drop commands there are but if there is one that acts like Collision_line you could use that.


try this in the step event: test expresion just as before: distance_to_point(player_obj.x,player_obj.y) <= 300
then put check var if y is less than player.y set the move direction after that to up with whatever speed

then the same test expression followed by:
check var if y is larger than player.y set the move direction to down after that to whatever speed

the same test expresion
check var if x is less than player.x set the move direction left to whatever speed

the same test expresion
check var if x is larger than player.x set the move direction to right to whatever speed.

Did that help, it should all be drag and drop.

Just to clarify your step event should look something like this:
:GM060:
:GM073:
:GM002:
:GM060:
:GM073:
:GM002:
:GM060:
:GM073:
:GM002:
:GM060:
:GM073:
:GM002:


The movement didnt work smoothly, thats why i did jump to position instead of move. And it worked perfect.

Thanks again, you've been a great help to me. :thumbsup:

did you do a jump to position for up down left and right, I'm just curious.
  • 0

#13 AJFaas

AJFaas

    GMC Member

  • New Member
  • 8 posts
  • Version:GM8

Posted 23 May 2012 - 07:15 PM




I have no idea what Drag and Drop commands there are but if there is one that acts like Collision_line you could use that.


try this in the step event: test expresion just as before: distance_to_point(player_obj.x,player_obj.y) <= 300
then put check var if y is less than player.y set the move direction after that to up with whatever speed

then the same test expression followed by:
check var if y is larger than player.y set the move direction to down after that to whatever speed

the same test expresion
check var if x is less than player.x set the move direction left to whatever speed

the same test expresion
check var if x is larger than player.x set the move direction to right to whatever speed.

Did that help, it should all be drag and drop.

Just to clarify your step event should look something like this:
:GM060:
:GM073:
:GM002:
:GM060:
:GM073:
:GM002:
:GM060:
:GM073:
:GM002:
:GM060:
:GM073:
:GM002:


The movement didnt work smoothly, thats why i did jump to position instead of move. And it worked perfect.

Thanks again, you've been a great help to me. :thumbsup:

did you do a jump to position for up down left and right, I'm just curious.


i replaced every move to, with a jump to. x -4, x 4, y -4, y 4.
  • 0

#14 Zoltan Kriven

Zoltan Kriven

    GMC Member

  • GMC Member
  • 342 posts
  • Version:GM8.1

Posted 23 May 2012 - 07:19 PM

Could you have figured this out on your own?
  • 0

#15 AJFaas

AJFaas

    GMC Member

  • New Member
  • 8 posts
  • Version:GM8

Posted 23 May 2012 - 07:35 PM

Could you have figured this out on your own?


Probably not, i didnt know about the option to do: if y is smaller than object.y.

Which will come in handy a lot more often probably if i wanna make a smart AI.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users