playMaker

Author Topic: Get Position / Set Position problem  (Read 4837 times)

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Get Position / Set Position problem
« on: January 03, 2017, 04:35:55 AM »
Hi guys,

i have a small spawner which is supposed to spawn gameobjects in a a pattern (spaceships spawning in arrow formation). Spawner is an empty object with an FSM which contains one state and the following actions:

Get Position - Getting the position in World space and storing it as Vector3 variable Spawner Position.



Spawning a GameObject - I'm using Core GameKit for spawning. Spawn Position Mode is set to Use This Object Position to Spawn on the place of the Spawner, and i store the Spawned Game Object as GameObject variable.



Set Position of a GameObject - For the GameObject whose position i want to set i choose stored GameObject variable, select Spawner Position for the Vector3, and adjust X, Y and Z position relative to Self Space.



But, the object sets it position relative to world space and it appears near the world center.

Any ideas what i'm doing wrong? I had a similar setup with with two different objects (Spaceship and a GunPoint spawning on a defined space on the spaceship) and things worked fine. Spaceship had the Get Position on itself, and it stored the position in vector3 variable in world space. The GunPoint had Set Position, used the Spaceship vector3, and Space set to Self and it worked, i don't know what's different here.
Available for Playmaker work

terri

  • Sr. Member
  • ****
  • Posts: 386
    • terrivellmann.tumblr.com
Re: Get Position / Set Position problem
« Reply #1 on: January 03, 2017, 06:32:57 AM »
Hard to say without seeing the whole picture, but world space and local space are different things.

I suggest first just checking if despite the result, the object's local position was set and matches the values you gave it.

Then try using InverseTransformPoint to convert the variable before assigning it.

In the case where it worked before, its likely that it was in a situation where the values happened to be the same, which happens when the object is at root level or its parent is at 0,0,0 in world space

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Get Position / Set Position problem
« Reply #2 on: January 04, 2017, 04:48:09 AM »
I don't know why am i getting the spawner position in the first place, the objects spawn on 0,0,0 of the spawner.

The way i see it, i should just set spawned objects' position relative to self, but they set themselves relative to world space (where 0,0,0 is world center), how come?
« Last Edit: January 04, 2017, 05:00:08 AM by krmko »
Available for Playmaker work

terri

  • Sr. Member
  • ****
  • Posts: 386
    • terrivellmann.tumblr.com
Re: Get Position / Set Position problem
« Reply #3 on: January 04, 2017, 05:37:43 AM »
Because you're getting the world space position and setting it as self space?
The variable itself is a Vector3, so just the XYZ values, it doesn't differentiate or convert between the two.

You can either get the spawner's world space and set the spawned's world space to match, or parent the spawned object to the spawner and set its self space to 0 0 0

edit: actually I think in your action you can just set it to spawn at the spawner's location so you wouldn't even need the other get/set position actions. I don't use that toolkit so I have no experience with it

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Get Position / Set Position problem
« Reply #4 on: January 04, 2017, 08:06:33 AM »
I created a simple cube in the scene for the sake of testing. In the Set Position action the Game Object is set to "Use Owner", Vector is set to "None", X, Y, Z are the desired values, and Space is set to "Self".

The action works as intended. When set to self, the center of the object itself is actually 0,0,0, and i just tweak it by entering values in X, Y, Z boxes.

YThe thing is, i have multiple objects spawning at the spawner location, and i need their positions set in a pattern, so i need to nudge each of them locally a bit. I excluded the whole Get Position of the spawner because it's irrelevant, when they spawn, they spawn exactly on the spawner, as intended, and set position should work normally, but instead of self, the spawned objects use world space. When they are spawned, they have nothing to do with spawner anymore, they're not parented or anything.

Only thing that comes to my mind that can cause trouble is that i save the spawned objects in gameobject variable so i can manipulate them, and then i set position via those gameobject variables. I'll try inverting the transform point to see if it does any good.

« Last Edit: January 04, 2017, 08:24:16 AM by krmko »
Available for Playmaker work

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Get Position / Set Position problem
« Reply #5 on: January 04, 2017, 09:19:44 AM »
Update:

things work as intended when i parent the spawned object under the spawner, but i don't want to insert more steps than intended, and i find this one more than unnecessary. What's the catch?
Available for Playmaker work