playMaker

Author Topic: Need help to join two gameObjects, then save the result.  (Read 8829 times)

robmuzz

  • Playmaker Newbie
  • *
  • Posts: 18
Need help to join two gameObjects, then save the result.
« on: April 07, 2013, 03:21:22 PM »
Hello,

I'm not new to Unity, but fairly new to Playmaker. I have NO programming skills (that's why I'm so excited by Playemaker.)

I am working on a standalone PC program. For testing at the moment, I'm nowhere near making a game yet.

I have one, two part, question...

1) I want to be able to snap object A to object B to create object C (A+B = C) like how that VAB or SPH in Kerbal space program does. I have got to the ponit where I can pick up the objects, but that's all. I assume you need to find the vector3 of both of them, but I really can't get my head round where to start.

2) Once I make object C I want it to be remembered via a simple save data file, but again, I have no idea how. I assume it'll be something to do with playerprefs?

Please can somebody guide me through these SLOWLY!

Thank you very much in advance,

Rob :)

robmuzz

  • Playmaker Newbie
  • *
  • Posts: 18
Re: Need help to join two gameObjects, then save the result.
« Reply #1 on: April 09, 2013, 04:43:53 PM »
I (hope) I have just uploaded the unity file to see what I have so far.... Nothing much really.

http://www.fileswap.com/dl/UF97VeB9P6/

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Need help to join two gameObjects, then save the result.
« Reply #2 on: April 09, 2013, 09:23:21 PM »
There is a fake way to do this... But I think you may be looking for a more scripted quality approach?

Making brand new meshes from a set of objects isnt really possible without custom help, but you can certainly create an empty game object prefab, set it as a parent to the A+B objects and use the empty game object prefab as your "C" then start doing everything to the C object as you want. It's basically the same thing, but with less technical potential than making a merge script.

You'll just have to orchestrate the spawn of the empty, attachment of the A+B and store the result as a variable then work with that. Should work fine, just takes some wiring up.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

robmuzz

  • Playmaker Newbie
  • *
  • Posts: 18
Re: Need help to join two gameObjects, then save the result.
« Reply #3 on: April 10, 2013, 09:05:37 AM »
Thank you for the reply.

I can give that a go, but the idea was to learn a robust method, I can impliment in an "editor" type scenario.

Rob.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Need help to join two gameObjects, then save the result.
« Reply #4 on: April 10, 2013, 09:19:56 AM »
I think that is outside the scope of the playmaker actions. If there is already a third party plugin that does that then you can request actions for that framework and go from there.

Otherwise the parenting system should work fine, depending on what exactly you need to do with the result.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

robmuzz

  • Playmaker Newbie
  • *
  • Posts: 18
Re: Need help to join two gameObjects, then save the result.
« Reply #5 on: April 10, 2013, 08:50:36 PM »
That's a shame, if that's the case.

My ideas are mainly based on UGC (User Generated Content) using editors and making things, so this seems like a pretty early stumbling-block.

Surely I'm not the only person who needs this type of mechanic?

Thank you for the advice, I'm going to keep an eye on this thread, and keep searching for a way anyway.


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Need help to join two gameObjects, then save the result.
« Reply #6 on: April 11, 2013, 01:48:59 AM »
Hi,

 for this kind of need, I would recommand using a database, and build a small framework around this feature.

when user connect A and B together, you save in the database this connection, so that when the user opens it again, you look up the database, find all the connection the user did and rebuild them.

Now, if you are debuting with Unity, and playmaker, that will definitly be a challenge, I would recommand you first get acquainted to the whole environment with simpler more "standard" features. But I have to admit I am like you... as soon as I start something, I am straight away into a situation where I need customization cause I have very specific needs... so I am with you all the way :). It's feasible, but you'll need to gain experience to master playmaker and Unity to achieve this properly.


Bye,

 Jean

robmuzz

  • Playmaker Newbie
  • *
  • Posts: 18
Re: Need help to join two gameObjects, then save the result.
« Reply #7 on: April 12, 2013, 02:14:00 PM »
I am not new to Unity and have mastered many mechanics, but I still don't see why, if you can write this as a script, why it can't be done in playmaker?

All I need is the process (for a simplified example) To take a location and GameObject and be able to add another to it and save the result.

I may have misunderstood the database idea jeanfabre, but to refer to a database for 2 or 3 parts would be ok, but for 10s or 100s the combinations would be in the millions.


Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4002
  • Official Playmaker Support
    • LinkedIn
Re: Need help to join two gameObjects, then save the result.
« Reply #8 on: April 13, 2013, 02:17:58 AM »
Do you have an example of a script that does this?
Is it an editor script? You can't author editor scripts with Playmaker.
Otherwise I'm sure we can figure out the Playmaker equivalent...

robmuzz

  • Playmaker Newbie
  • *
  • Posts: 18
Re: Need help to join two gameObjects, then save the result.
« Reply #9 on: April 13, 2013, 06:41:38 AM »
I don't have a script that does this, I was simply saying, it is done all the time in games.

I just think that Playmaker seems so powerful, that something as simple as this should be easy.

I spend a while yesterday trying to get a system going, where when a collision event is triggered (by the proximity of the object B) Object B would snap to the attachment vector3 of Object A's attachment node.

I think I have now learned enough about player prefs to be able to store the result. but it's just proving hard to get the objects to link.

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4002
  • Official Playmaker Support
    • LinkedIn
Re: Need help to join two gameObjects, then save the result.
« Reply #10 on: April 13, 2013, 12:17:39 PM »
At runtime games would normally just parent objects. At edit time they would use something like Combine Meshes which I believe ships with Unity.

Parenting is normally done in the course of gameplay, e.g., parenting a weapon to an attach point. This is fairly easy to do in Unity/Playmaker.

Full game editors are a more complex and far less common use case that normally involves saving a custom data file that describes the level. Some of these editors also optimize the built level using some kind of Combine Mesh. If your levels are simple you might not need this...

It all depends on the type of editor you're making.

Do you need to physically link the objects?
Can you just save the positions?

You can't save GameObject references in PlayerPrefs, but you could save object names and use Find Object. But the names would have to be unique.

robmuzz

  • Playmaker Newbie
  • *
  • Posts: 18
Re: Need help to join two gameObjects, then save the result.
« Reply #11 on: April 14, 2013, 08:42:12 AM »
Thank you Alex,

I think it would be best if explain what I plan to do...

My idea is to have a set of parts, you can put together (like lego) to make vehicles. Starting simple at first, front, middle and rear sections.
Then the user can save the result and view it in a showroom or something.

Once I knew how to do it, I did plan on makeing more complex editors, but it might be a bit out or my scope at the moment.
« Last Edit: April 14, 2013, 11:04:59 AM by robmuzz »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Need help to join two gameObjects, then save the result.
« Reply #12 on: April 14, 2013, 08:58:11 AM »
Well if thats all you're doing then i dont see any need to join the meshes or do anything elaborate, you could probably make an array with the item IDs and their transform and have it rebuild the model based on that info. (I havent got into arrays yet, so I'm not sure how it works but this could work I think.)

Or just child all of the lego objects to the wrapper parent when they're done and store that as a prefab. This would be more expensive. I'm not sure how to save things as new data but I'm sure there is some info on saving around here.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

robmuzz

  • Playmaker Newbie
  • *
  • Posts: 18
Re: Need help to join two gameObjects, then save the result.
« Reply #13 on: April 14, 2013, 11:07:06 AM »
Thanks Lane,

I don't know anything about arrays really, but I assume it's like a collection or list of variables?

I'll look into them and see how to go from there.

robmuzz

  • Playmaker Newbie
  • *
  • Posts: 18
Re: Need help to join two gameObjects, then save the result.
« Reply #14 on: April 16, 2013, 05:23:03 PM »
I may have solved it.

I've been thinking far too complicated, it's really simple actually. I decided to use "set parent" then save the object (gameObject) as a variable in the player prefs.

You lose the identity of part B, but I assume you can unparent fairly easily.

Thank you to everyone who helped.