playMaker

Author Topic: [SOLVED]problem with move towards  (Read 2221 times)

Dustiwi

  • Playmaker Newbie
  • *
  • Posts: 28
[SOLVED]problem with move towards
« on: January 10, 2022, 11:51:46 AM »
hi, I'm having a weird issue with move towards, a have an enemy that simply moves towards the player as longs as he's inside the collider, i dragged the enemy prefab into the map and it works fine, but when i use create object to make it spawn as an object(clone), move towards now works backwards, instead of moving towards the player when entering the collider, it gets away from the player, i just cant get my head around what's going on, is it a glitch in playmaker or unity?
« Last Edit: January 11, 2022, 01:00:00 PM by Dustiwi »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: problem with move towards
« Reply #1 on: January 10, 2022, 09:51:58 PM »
Hi.
when its spawned as a prefab it will not find the player object.

prefab object can not communicate with scene objects (also when its a prefab that was spawned in the scene.

what you can do is :
Create a Global Variable "Player" then on player use set owner and target the global variable.

on the enemy target the global player variable.

another way would be 'Find Game Object' but you should only do that at the start of a scene, not during gameplay.

Dustiwi

  • Playmaker Newbie
  • *
  • Posts: 28
Re: problem with move towards
« Reply #2 on: January 11, 2022, 09:42:32 AM »
oh i understand, the only part that im lost is the set owner on the player, where can i find that?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: problem with move towards
« Reply #3 on: January 11, 2022, 09:48:08 AM »
Hi.
Sorry, i mean 'Get Owner' or 'Set Game Object'

Dustiwi

  • Playmaker Newbie
  • *
  • Posts: 28
Re: problem with move towards
« Reply #4 on: January 11, 2022, 09:51:25 AM »
also, do i make a new fsm for doing just that action?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: problem with move towards
« Reply #5 on: January 11, 2022, 12:22:19 PM »
Hi.
No, you can place it on any fsm on a start state on the player

Dustiwi

  • Playmaker Newbie
  • *
  • Posts: 28
Re: problem with move towards
« Reply #6 on: January 11, 2022, 12:59:43 PM »
jeeeez thank you it worked, i was really upset i couldnt figure that one out
thank you very much