Jump to content


Photo

Spawning


  • Please log in to reply
3 replies to this topic

#1 Devinit_gD

Devinit_gD

    GMC Member

  • New Member
  • 232 posts

Posted 25 August 2011 - 05:26 PM

I am using a spawning system in my game and i wanted to see if this code is ok:

if distance_to_object(obj_player)>80 and global.light=true
{
instance_create(x,y, obj_mob)
}
else
{
instance_create(x,y, obj_air)
}
  • 0

#2 Devinit_gD

Devinit_gD

    GMC Member

  • New Member
  • 232 posts

Posted 26 August 2011 - 04:44 AM

Anyone?
  • 0

#3 oblivious

oblivious

    GMC Member

  • New Member
  • 91 posts

Posted 26 August 2011 - 07:19 AM

Anyone?


What exactly do you wanty from us? if you want to check if it works, make a new file in game maker.

what the code does is check if the distance to object player is more then 80 and global.light = true it creates an instance of obj_mob and otherwise it creates an instance of obj_air. the only problem is that you didn't define the x and y of where to spawn those instances
  • 0

#4 filulilus

filulilus

    GMC Member

  • GMC Member
  • 928 posts
  • Version:GM:Studio

Posted 26 August 2011 - 07:25 AM

That code works perfekt as a spawn point, you just forgot one thing.
If you have more then 1 expression you have to surround them with the "(" and the ")" chars.

These examples do work:
if (x = 100 && x = 100) {}
if x = 100 {}

This example do NOT work:
if x =100 && y = 100 {}


As for your code, change
if distance_to_object(obj_player)>80 and global.light=true
into
if (distance_to_object(obj_player)>80 and global.light=true)

Edited by filulilus, 26 August 2011 - 07:26 AM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users