playMaker

Author Topic: Get Position Problems  (Read 2187 times)

Webtech

  • Playmaker Newbie
  • *
  • Posts: 5
Get Position Problems
« on: January 13, 2015, 08:08:35 AM »
Hi there,

Im having trouble with the Get Position action. It permantly stays at 0.

I have at the start of the action a 'Collision 2d Event' which stores the Collider into a variable which I can see fine. The next step is that it uses Get Position to attain the 'X' property from the stored object. X is always zero.

If I breakpoint the FSM and then in the Hierarchy find the colliding object I can see the 'X' position is never zero.

Any ideas? The coliding object is one instantiated from a prefab but thats why I store the colliding object and check that one.

Little stuck.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Get Position Problems
« Reply #1 on: January 13, 2015, 08:18:16 AM »
2D works on the Y and Z planes only.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Webtech

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Get Position Problems
« Reply #2 on: January 13, 2015, 08:28:23 AM »
Are you sure?

Just I'm sitting here right now and in the Scene View I can adjust my objects (sprites) position using the transforms->Position->X and my object moves left and right on the scene. I also within playmaker set the X position to -10 or 10 to determine if the object will start from the left or right side of the screen.

To me, in 2D. X is left and right, Y is up and down and Z is Depth (Well drawing order in 2D).....

I'm only using the 2D collider to determine what object hit, after that its the standard Get Position action....

very Confused now.

Webtech

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Get Position Problems
« Reply #3 on: January 13, 2015, 08:55:58 AM »
A bit more digging inbetween doing something else and I figured out that it isn't the Get Position with the error. It's the 2d Collider. I'll have to see properly whats going on to see if it is my fault or a general bug but looks like the Collider it stores is wrong. It name's it correctly, highlights the right one in the heirachy view but doesn't show all the scripts attached etc until I double click the highlighted on in the hierarchy view. Not sure if I'm getting a child of the object I want yet. Will check in a bit.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Get Position Problems
« Reply #4 on: January 13, 2015, 09:12:23 AM »
Get Position should return a Vector3 (XYZ) but in Unity 2D, Y is vertical and Z is horizontal while X is depth. The 2D Physics system operates on Vector2's with the Y and Z planes only. X is not considered. You can change the X depth but the physics system will not care so there are a few things to consider when using the 2d colliders in this way.

Get Position will store the full transform XYZ of an object. It's possible you're overriding it after it is stored.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D