Jump to content


Photo

Getting 1 instance to follow another instance


  • Please log in to reply
2 replies to this topic

#1 BlaCkBlitZ

BlaCkBlitZ

    GMC Member

  • New Member
  • 10 posts
  • Version:GM8

Posted 13 June 2012 - 05:04 AM

Hi guys, how do you get 1 specific instance to follow another specific instance?

E.g. object customer is created and is happy, object happy is created and will follow above the customer. Same goes for sad.

- I use a controller to set a variable(customer) to each customer object created.
- Then I used the "with customer" function to choose between happy or sad.
- put an "if" check to check if customer is happy or sad and to create the appropriate face. This is set to variable 'thought_bubble'.
- I placed another "with thought_bubble" function within the "with customer" to make it follow customer.


This is what I attempted to do... But I could only get the face to appear, but not to follow the customers which would be moving across the game-space.

if instance_number(obj_customer_1) < 15
{
customer = instance_create( 959, random_range(128, 448), obj_customer_1)
with customer
{
preference = irandom_range(1,4)
if preference = 1
{
preference_bubble = instance_create( controller_customer.customer.x - 25, controller_customer.customer.y - 25, obj_preference_restaurant)
with preference_bubble
{
x = controller_customer.customer.x - 25
y = controller_customer.customer.y - 25
}
}
}



alarm[0] = choose(15,30,60,90)
}


Edited by BlaCkBlitZ, 13 June 2012 - 05:08 AM.

  • 0

#2 ZyklonMiraj

ZyklonMiraj

    GMC Member

  • GMC Member
  • 136 posts
  • Version:Unknown

Posted 13 June 2012 - 05:18 AM

instead just make a sprite and do this

if happy="true" sprite_index=spr_happy
else
sprite_index=spr_sad
hope u understand.
  • 1

#3 BlaCkBlitZ

BlaCkBlitZ

    GMC Member

  • New Member
  • 10 posts
  • Version:GM8

Posted 13 June 2012 - 06:41 AM

instead just make a sprite and do this

if happy="true" sprite_index=spr_happy
else
sprite_index=spr_sad
hope u understand.


Ahh thanks! I understand it fully and well.
It will take more photoshopping on the art end but I think it's a better alternative than cruching my brains over code.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users