playMaker

Author Topic: Object moves towards the player[SOLVED]  (Read 2717 times)

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Object moves towards the player[SOLVED]
« on: July 20, 2014, 09:02:51 AM »
Hi!
I have a little problem. I try to make magnetic coin which moves towards the player when I enter the trigger. And it works very well if the coins are in the scene, but the problem I have, is that it is a prefab I'm going to use. It create automatically coins.

This is what I do:
On the coin, I have "On Trigger Enter" And then I use the action "Move Towards", but since this is a prefab, I can't use my player in the scene as a Target Object.

Is it a way to solve this?

I will be very grateful for some help with this. :)
« Last Edit: July 21, 2014, 08:52:48 AM by jeanfabre »
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: Object moves towards the player
« Reply #1 on: July 20, 2014, 09:45:32 AM »
Save your player character as a Global GameObject (at runtime), then reference that in your Move Towards action?

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Object moves towards the player
« Reply #2 on: July 20, 2014, 09:56:34 AM »
Hi!
Maybe it's a stupid question. How do I save my character as a Global GameObject?
Maybe I should know it.
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: Object moves towards the player
« Reply #3 on: July 20, 2014, 10:16:03 AM »
Create your global variable. Then put a 'Set Game Object' action on your character prefab, select your global variable, and drag your prefab onto the gameobject field.

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: Object moves towards the player
« Reply #4 on: July 20, 2014, 10:17:41 AM »
Or alternatively from the Global Variable window, highlight your gameobject variable and drag your prefab onto it.

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Object moves towards the player
« Reply #5 on: July 20, 2014, 10:18:40 AM »
Forget it! I made it. Very simple
Just made a Global Game Object.
And on the player object, I use the Action "Set Game Object"
And then I use the Global Game Object on the "Move Towards" Action :)
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Object moves towards the player
« Reply #6 on: July 20, 2014, 10:20:33 AM »
I was writing when you replied. But thank you :)
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

flora

  • Playmaker Newbie
  • *
  • Posts: 47
Re: Object moves towards the player[SOLVED]
« Reply #7 on: July 26, 2014, 08:21:54 AM »
forgive me for the question, but how do you create a global game object ? :)

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Object moves towards the player[SOLVED]
« Reply #8 on: July 26, 2014, 11:03:16 AM »
Hi!

Just go to Global Variables and create a new variable and set it to GameObject.
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

flora

  • Playmaker Newbie
  • *
  • Posts: 47
Re: Object moves towards the player[SOLVED]
« Reply #9 on: July 26, 2014, 05:52:51 PM »
i had not see the little button on the bottom, sorry  ... your thread has helped me a lot ... i have just dicover global variables !!! thank you  :)