playMaker

Author Topic: (SOLVED) Create Object spawns NGUI objects at 0 0 0 Worldspace no matter what  (Read 3919 times)

snake377

  • Playmaker Newbie
  • *
  • Posts: 10
Hello and thank you for taking the time to read my issue!

I have been using playmaker for a few months, and overall it works wonderfully. However, I am having a very hard time using the CREATE OBJECT Action to make game objects appear where I want them to.

Basically I have a Prefab object spawn once a button is clicked. However no matter what I do it ONLY spawns at X0 Y0 Z0 position. I want it to spawn at the same location that is stored in the Prefab though, not 0 0 0.

I have tried specifying the spawn point in the Action Editor, but it just makes no difference in terms of where the object is created. The only thing I have noticed is that if I tell the Spawn Point to be the same as the Game Object I am "Creating", it  creates the game object at 0 0 0, but when I mouse over the object it tweens to the correct position.

This is incredibly confusing and I can't find a solution anywhere. If anyone can help me in correcting this matter, you would be my personal hero! I am open to any suggestions or resolutions that may help in this matter.

Thank you for your time!!!!
« Last Edit: September 30, 2014, 12:11:01 PM by snake377 »

RC

  • Full Member
  • ***
  • Posts: 148
Re: Create Object spawns objects at 0 0 0 Worldspace no matter what
« Reply #1 on: September 26, 2014, 05:20:09 PM »
An upload of the sample would be much easier to understanding and figuring out the problem?
I have gone through that in the past and would like to see if I can help out if you can upload a sample.

snake377

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Create Object spawns objects at 0 0 0 Worldspace no matter what
« Reply #2 on: September 29, 2014, 11:56:47 AM »
Here are screenshots showing what is happening when I am trying to create objects.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Create Object spawns objects at 0 0 0 Worldspace no matter what
« Reply #3 on: September 29, 2014, 12:27:58 PM »
You cant store world coordinates in a prefab. Use the position variable in the create action to put in the coordinates.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

snake377

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Create Object spawns objects at 0 0 0 Worldspace no matter what
« Reply #4 on: September 29, 2014, 12:46:27 PM »
I have entered the position manually and it still spawns at 0 0 0. :(
I also toggled the SPAWN POINT to nothing and issue persists. See screenshot.


Thank you for taking the time to assist!

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Create Object spawns objects at 0 0 0 Worldspace no matter what
« Reply #5 on: September 29, 2014, 12:48:27 PM »
Why is prefab also the spawn point? Are you referencing something in the project hierarchy as the position to spawn at? Only existing scene objects can be referenced in that field, if you specify something there then anything in the position field is used as an offset from that object.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

snake377

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Create Object spawns objects at 0 0 0 Worldspace no matter what
« Reply #6 on: September 29, 2014, 12:52:16 PM »
Oh thank you for clarifying that, I have removed the prefab for the spawn point and manually set the position I want to to create the object at, however it is still occuring at 0 0 0. Here are some screenshots to show it more clearly. I am at a total loss :(

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Create Object spawns objects at 0 0 0 Worldspace no matter what
« Reply #7 on: September 29, 2014, 01:00:04 PM »
How is your PREFAB object getting set as a child of the UI Root? You probably have some other scripts on it that are interfering with the position.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

snake377

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Create Object spawns objects at 0 0 0 Worldspace no matter what
« Reply #8 on: September 29, 2014, 01:07:06 PM »
The PREFAB was a Sprite that was created within NGUI. I believe that is why it keeps getting thrown into that UiRoot from whence it originated before I made it a prefab. (And NGUi requires it's elements to be within a UiRoot) Here are the PREFAB properties attached.

snake377

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Create Object spawns objects at 0 0 0 Worldspace no matter what
« Reply #9 on: September 29, 2014, 01:23:54 PM »
So it does appear to be limited to NGUI elements having this issue. I tested the CREATE OBJECT Action using normal game objects (Not NGUI stuff) and it works perfectly using the Position method you suggested:

So I guess the true issue at hand, is not being able to create NGUI elements using the CREATE OBJECT Action in Playmaker. It creates the NGUI elements, but only at 0 0 0. :/
« Last Edit: September 29, 2014, 01:25:48 PM by snake377 »

mweyna

  • Full Member
  • ***
  • Posts: 242
Re: Create Object spawns objects at 0 0 0 Worldspace no matter what
« Reply #10 on: September 29, 2014, 01:49:57 PM »
In theory if UIRoot was perfectly zero'd it would spawn at the right point. However, the workaround could be spawn/create the object at -10,000 and then SetPosition it to the right world position. I've used that approach with some success, the issue it tends to create is for a frame it may pop, so you'd just need to add another layer of complexity where you don't turn on any geo until after it's in the proper place.

snake377

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Create Object spawns NGUI objects at 0 0 0 Worldspace no matter what
« Reply #11 on: September 30, 2014, 12:10:47 PM »
I GOT IT!!! It was the fact that I was trying to spawn prefabs from another project. Apparently something in the prefab's properties was jacking up the spawn location. But after making a fresh NGUI Button and attaching the Playmaker FSM and Proxy it works PERFECTLY!!! That was a HUGE obstacle that has been resolved thank the Unity gods!

Thank you all for taking the time to help!!!!!