playMaker

Author Topic: Unity 2D and Physics 2D Support now available  (Read 39733 times)

cloud03

  • Full Member
  • ***
  • Posts: 249
  • Viva Playmaker!
    • Milkish Game Studios Blog
Re: Unity 2D and Physics 2D Support now available
« Reply #15 on: November 26, 2013, 01:01:09 AM »
Glad to help....

I'm also a newbie with playmaker, and indeed is an awesome tool....I'm already addicted to it....LOL :)

elvis75k

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 97
    • nRender
Re: Unity 2D and Physics 2D Support now available
« Reply #16 on: November 26, 2013, 09:29:24 AM »
Hi, I'm trying to make a moving platform using the PlayMaker Unity2D addons. All i want to do is parenting the character to the platform.. but seems that triggers doesn't work without rigidbodies and this make it impossible for me to go on. Any idea?

cloud03

  • Full Member
  • ***
  • Posts: 249
  • Viva Playmaker!
    • Milkish Game Studios Blog
Re: Unity 2D and Physics 2D Support now available
« Reply #17 on: November 26, 2013, 10:08:47 AM »
It's working here, and I'm using collision enter 2D event, not trigger...

how I do it, is by using only box collider for the moving platform object, and give it a "MovingPlatform" as a tag, this will be the tag that we'll test later on collison.

And then I add another FSM script on the character just for handling while on Moving Platform object, just like the sample above, I'm using the 1st state to wait when collison happens, and if its happening the 2nd state will store the game object hit to a variable, after that the game object stored will be tested its tag, if it is "MovingPlatform" as the tag, it will be send to the 3rd state, else it will go back to 1st state to wait another collision...

for the 3rd state, this is where the parenting happens....see the image attached below.

Hope this helps...

elvis75k

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 97
    • nRender
Re: Unity 2D and Physics 2D Support now available
« Reply #18 on: November 26, 2013, 10:43:41 AM »
Thank You! Unfortunately my 2D character controller is not working.. I think we need a new character controller entirely made with playmaker.
« Last Edit: November 27, 2013, 05:43:22 AM by elvis75k »

dasbin

  • Junior Playmaker
  • **
  • Posts: 92
Re: Unity 2D and Physics 2D Support now available
« Reply #19 on: November 29, 2013, 04:36:03 PM »
I'm just curious if native support is coming (ie no need to add the proxy components) to Playmaker, or if this will remain the 2D physics solution for the foreseeable future.

dasbin

  • Junior Playmaker
  • **
  • Posts: 92
Re: Unity 2D and Physics 2D Support now available
« Reply #20 on: November 29, 2013, 05:07:07 PM »
Additionally I wonder how one would make an action similar to the "Collision Event" action which specifies a type of collision and tags of the collided objects. Then it is possible to remain inside a state until the correct collision happens only (important if you doing something every frame inside the same state, like animating a variable).

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Unity 2D and Physics 2D Support now available
« Reply #21 on: November 30, 2013, 12:46:17 PM »
Hi,

 "collision Event" is already done, I need to wrap it all up into a package, which will be made available beginning of next week most likely.

 As for proxies, Currently, I think it will remain with proxy for now. There is no performance penalty in using proxies, so don't worry, it's nothing to worry about on that front.

 Bye,

 Jean

dasbin

  • Junior Playmaker
  • **
  • Posts: 92
Re: Unity 2D and Physics 2D Support now available
« Reply #22 on: November 30, 2013, 03:07:43 PM »
Hi Jean,

I've been working on making a bunch of actions for the new 2D system, and was working on a Physics2D.Raycast action.

However I don't know how to store the hit info. PM seems to have a built-in space to store hit info called "Fsm.RaycastHitInfo" which I'm assuming isn't compatible with storing the new RaycastHit2D.

Is there a best way to store the info to be accessed by a subsequent "Get 2D Raycast Hit Info" action like the 3D version?

I was thinking of modifying your proxy script, actually, to provide a place to store this. But it is more complicated than I thought because that could only store one "last raycast hit info" per gameobject, when what you want is one per FSM. (Multiple raycasts being sent from different FSM's on one game object would get confused with each other).

I will release all these actions (there are a lot of them, including all possible Vector2 manipulations) on this forum when I'm done.
« Last Edit: November 30, 2013, 03:27:51 PM by dasbin »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Unity 2D and Physics 2D Support now available
« Reply #23 on: December 02, 2013, 01:42:06 AM »
Hi,

 I am about to release all of this in the next few hours. and it features what you are trying to achieve. Basically, one way is to create a static dictionnary to store hit info against a specific Fsm. and in your action you simply add/update an entry fsm->hit info, and the get info action simply query the info for the same Fsm reference.

 Be careful with this, you need to do some clean up, at least when a new level is loaded, else if the game is long this dictionnary will get bigger and bigger if used a lot and will cause memory problem eventually ( unlikely, but if this technic is over used, it will).

However, in all case, I recommend you get the info in the actual initial action, it's easier and direct.

 Bye,

 Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Unity 2D and Physics 2D Support now available
« Reply #24 on: December 02, 2013, 06:36:06 AM »
Hi,

 Released. Have a go at this package:

https://hutonggames.fogbugz.com/default.asp?W1150

 study how I save and retrieve the collision and raycast info in the PlayMakerUnity2dProxy and in actions such as GetCollision2dInfo, GetRayCastHit2dInfo and RayCast2d

 Any questions or issues, let me know :)

 Bye,

 Jean

elvis75k

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 97
    • nRender
Re: Unity 2D and Physics 2D Support now available
« Reply #25 on: December 02, 2013, 07:24:42 PM »
Ok i think i'm going mad now: i've updated to unity 4.3.1, all new pm unity2D but i can't have collision or trigger without adding rigidbodyes. It's just me? Somebody is also in trouble here and here!.
@jeanfabre look HERE and let me know if we have to wait the unity2D tutorial to being ported to pm (to understand this things) or wait for upcoming unity bug fixes..
Thanks  :P
« Last Edit: December 02, 2013, 07:40:27 PM by elvis75k »

dasbin

  • Junior Playmaker
  • **
  • Posts: 92
Re: Unity 2D and Physics 2D Support now available
« Reply #26 on: December 02, 2013, 11:12:35 PM »
That is normal and intended behaviour. It is a limitation of physics engines.
Scroll to the bottom of this page and read the "Collision action matrix"

http://docs.unity3d.com/Documentation/Components/class-BoxCollider.html

In reality some things registered triggers and collision in 3D Physx that actually weren't supposed to, and that's why we got away without rigidbodies sometimes in 3D physics. But it wasn't intended to be that way.

funshark

  • Playmaker Newbie
  • *
  • Posts: 23
Re: Unity 2D and Physics 2D Support now available
« Reply #27 on: December 12, 2013, 08:08:44 PM »
Here is what I do, the robot shoots arrowIcon when fire1 pressed, and the robot have different tag with the arrowIcon, for the Crate Object, I created a FSM that listening for collision on the first state (first state does not contain any action at all), with Transition Collision enter 2D, when any object collides with the crate, it will automatically activate that transition.

On the second state, the first action will store the game Object that hits the crate, and we will check if that game object have certain tag that we're testing, if its true, then go to destroy, else it will go to Don't destroy transition. I've tested it, and it works, the crate only can be destroyed if its collides with arrowIcon, if I try to move the robot to collide the crate, it will not be destroyed.

hope this helps (I've attached the FSM for the crate)

Just curious here;
I see you have a character made with body parts and hopefully animated with Unity (?).
Have you managed to drive the animations you've made in Playmaker?

cloud03

  • Full Member
  • ***
  • Posts: 249
  • Viva Playmaker!
    • Milkish Game Studios Blog
Re: Unity 2D and Physics 2D Support now available
« Reply #28 on: December 13, 2013, 01:05:17 AM »
Unfortunately I haven't managed to get the new animator to work with playmaker, I guess we have to wait until playmaker release an update for the animator package, hopefully it will be available on xmas according to this post:

http://hutonggames.com/playmakerforum/index.php?topic=5741.msg27696#msg27696

dasbin

  • Junior Playmaker
  • **
  • Posts: 92
Re: Unity 2D and Physics 2D Support now available
« Reply #29 on: December 15, 2013, 03:23:32 PM »
Jean, just found a little bug with the proxy when resetting the level (loading the same scene you're already in):

NullReferenceException: Object reference not set to an instance of an object
PlayMakerUnity2d.OnLevelWasLoaded (Int32 level) (at Assets/PlayMaker Unity 2D/Scripts/PlayMakerUnity2d.cs:89)