Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: cel on June 06, 2019, 01:35:58 PM

Title: help with custom action [SOLVED]
Post by: cel on June 06, 2019, 01:35:58 PM
I copied the action create advanced code in order to create primitives, it works but, when i change the spawn position (x=2,y=0,z=0) it creates two primitives. Could someone have a look at the attachment and find out what is going on wrong?
Title: Re: help with custom action
Post by: Deek on June 07, 2019, 07:29:49 PM
The problem is that "GameObject.CreatePrimitive()" already creates an instance of the given primitive type and as you later instantiate a new GameObject you end up with two new objects, regardless of the specified position (you likely just noticed because they weren't overlapping anymore).

The solution is to use the reference to the created primitive (the variable "go") instead of instantiating a it a second time.

I've added the fixed script to the attachments and took some liberties with the naming and improved the formatting, as well as adding comments to make it more clear what's going on.
You might compare the two versions to better understand what was causing that behavior.
Title: Re: help with custom action (solved)
Post by: cel on June 09, 2019, 06:14:36 AM
brilliant, thanks for your help Deek