PlayMaker Help & Tips > PlayMaker Help

Prefab Create object uses old collider

(1/2) > >>

DanielThomas:
I got a problem using collider2D. I have buildings as prefabs and you can place them down in the scene.

In Playmaker I create an game object from the prefab, I do "on enter" and "on exit" actions on it. (to see if it can be placed on ground) This works so far. I place it down. But when I create a new game object (using same FSM and actions) from the same prefab it's getting weird, the collider used for test is the first game object. So the collision test is true or false based on if the first game object I had is colliding - not the new GO I created.

Is this someone seen before?

DanielThomas:
Here's some visual hints, the FSM is cleaned down to the bare bone to isolate the problem.





EDIT: I also tried have a different gameobject prefab created after the first one, it still use the first GO collider. I looked a little in the action script of trigger2D event but don't understand all of it, is there a chance the collider is cached and don't update or something?

djaydino:
Hi.
It might be better to use 'On Trigger Stay' instead of 'On Trigger Enter'
and you can find some actions on the Ecosystem to set the color instead of using set property

Now i do think you setup is wrong, try this :

After 'Create GameObject' use the 2 trigger events only once to know on spawn if it can place or can't. and remove the Get Fire1 Down action

Then in reset color add a trigger2D Event (On Trigger Exit) and conntect to 'Can't Place'
Also add the 'Get Fire1 Down' and connect to 'has building'.

Then in 'Can't Place add a trigger2D Event (On Trigger Stay) and connect to 'reset color'

I hope you understand, if not let me know and i will make a sample tomorrow.

DanielThomas:
I tried but same result. The first created object is the one giving the collision result.
I also tried in a fresh new project and got same result.
What I'm doing in short, tried in a fresh project:
I have a prefab with sprite renderer, box collider(set to trigger) and a rigidbody2D(no gravity).
I have an empty object in the scene with the FSM.

- Start
"Create Object". Store in gameobject variable
with stored gameobject Use Trigger2D stay and exit between two states
I click and I restart and go to - Start state.

I redo the FSM loop a few times to just have objects to collide with. The last object I have while the FSM is looping through the trigger tests doesn't make the triggers fire. If I now grab the first object I created with the FSM and move it around - THIS makes the fsm fire the trigger event - even though it's not currently stored in the game object  variable that's used in the trigger action.

Anyone else who can reproduce this? It must be a problem with the action since I try with a fresh project and it's just a few actions.

Let me know.

djaydino:
Hi, could you pm a link to the project so i can test and try to find a solutior (or to confirm that it is a bug.

Navigation

[0] Message Index

[#] Next page

Go to full version