Playmaker Forum
PlayMaker News => General Discussion => Topic started by: jeanfabre on November 15, 2013, 05:02:11 AM
-
Hi Everyone!
Finally gathered the first package for Unity 2D.
The most important in Unity 2D to take control over with PlayMaker is the new Physics 2D engine. With this package, you can now receive Triggers and Collisions events in your Fsm very much like with the normal Physics engine.
You can download now the package on the wiki:
https://hutonggames.fogbugz.com/default.asp?W1150
The wiki documents how to set up your scene to enable PlayMaker and Physics 2D to work together. If you have any questions, let me know.
I am currently working on refactoring the Unity 2D game Sample from the asset store, so.
More actions will be added to this package as we go, so don't hesitate to make requests and hilite what you would like to see supported next.
Bye,
Jean
-
I'm getting the 'Assets/PlayMaker Unity 2D/Scripts/PlayMakerUnity2d.cs(3,7): error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing a using directive or an assembly reference?' error when I try to export to Webplayer.
-
D'oh!
I rushed the editing features it seems...
Simply delete the "PlayMaker Unity 2D" Folder and redownload form the wiki. Sorry about that.
Bye,
Jean
-
Any chance that "Mouse Pick Event" soon will be able to handle 2D Physics to?
Hi,
Yes, this will come next as I finish the refactoring of the Unity Sample.
Bye,
Jean
-
Is there any way to make the 2D Collisions and Triggers work like Collision Event and Trigger Event? as the current system really limits what i can do.
-
Hi,
They actually are exactly the same in their implementation, can you be more precise as what you experience?
Bye,
Jean
-
Hi jean, this is my first post, and I've really excited learning playmaker so far...it is a really great tool...
I'm wondering with the playmaker 2d add ons, how do I add force or velocity to 2d rigidbody game object? is it already possible?
-
Hi Jean
Ok so we have an object listening for triggers or collisions to happen, i've found the main problem is i can't define which collisions or triggers its listening for like i can with Trigger Event or Collision Event, instead the moment that object collides with anything all Collision Enter globals are called and some of them i don't want to call until the object collides with other objects.
So yeah i can't figure out a way to define what objects are colliding with each other via Tag like i can with Trigger Event and Collision Event
EDIT
Turns out i was over thinking things and after a little more experimenting i now understand how it works.
So thanks again Jean :)
-
Sorry for asking again, but for 2d we only have get collision info 2d and get trigger info 2d for action, how do we manipulate 2d objects using action such as add force, set velocity and others that are compatible for 2d objects?
-
How i did it was store the object hit in the Game Object Hit variable, then used the action Game Object Compare to compare the objects and send an event.
-
How i did it was store the object hit in the Game Object Hit variable, then used the action Game Object Compare to compare the objects and send an event.
Hi, I've tried what you said and I can't seem to get it to work. I'm also really new with this. I've attached images of what I have so far. Any help would be greatly appreciated.
Update:
Okay so I've got the 2D collisions working. Now I want to be able to specify what happens when certain collisions happen. In my game you're a ship that shoots missiles, and if you hit an asteroid then it gets blown up. so far that part works, but I've found that the asteroids get destroyed even when the ship hits them. I don't want this to happen and I was wondering how I could make sure only missiles destroy asteroids?
-
one way to do that, after the event "collision enter 2D", create a state between that contains "get collision 2D info" action, and store the game hit to a variable, and then compare the game objects, if its the missile, send the event to a state that'll destroy the asteroids, else do nothing...
-
one way to do that, after the event "collision enter 2D", create a state between that contains "get collision 2D info" action, and store the game hit to a variable, and then compare the game objects, if its the missile, send the event to a state that'll destroy the asteroids, else do nothing...
Thanks for the quick response. I'm trying to figure out what you are explaining, but I keep failing. Here are some pictures of what I have so far. What should I fix?
-
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)
-
THANK YOU SOOOOO MUCH!! ;D ;D ;D
This is exactly what I was looking to accomplish. It'll also help for when I'm trying to do other things. I'm still learning the basics of PlayMaker so this kind of thing is a (relative) quantum leap, hahah. I hope your day is going well!!
-
Glad to help....
I'm also a newbie with playmaker, and indeed is an awesome tool....I'm already addicted to it....LOL :)
-
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?
-
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...
-
Thank You! Unfortunately my 2D character controller is not working.. I think we need a new character controller entirely made with playmaker.
-
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.
-
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).
-
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
-
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.
-
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
-
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
-
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 (http://forum.unity3d.com/threads/214681-Collision-detection-without-RigidBody2D/) and here! (http://issuetracker.unity3d.com/issues/rigidbody2d-with-kinematic-rigidbody-will-not-cause-ontriggerenter2d/).
@jeanfabre look HERE (http://answers.unity3d.com/questions/575438/how-to-make-ontriggerenter2d-work.html/) 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
-
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.
-
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?
-
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
-
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)
-
Hi,
Good catch, please redownload from the wiki page,
Thanks,
Jean
-
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?
I've tested and it works, apparently you can create 2d animation in 4.3, and drive it with playmaker, just follow the step Jean posted (thanks to Lea Hayes):
http://hutonggames.com/playmakerforum/index.php?topic=3186.msg28121#msg28121
-
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?
I've tested and it works, apparently you can create 2d animation in 4.3, and drive it with playmaker, just follow the step Jean posted (thanks to Lea Hayes):
http://hutonggames.com/playmakerforum/index.php?topic=3186.msg28121#msg28121
Yes, you can create hierarchical animations that way, but not Sprite animation
-
Owh, okay, just tested with sprite animation, and it is not working....the robot in my example was created using hierarchical animation, so I thought you we're asking about that one...
-
Yes, I was asking about that one and at this moment, I didn't know we were able to create legacy animations :)
But now it's fine, all works perfectly (as far I've tested ) with the mecanim update for playmaker :)
-
Hahahah yup, just check another thread, and there is the surprise, the new animator package for 4.3....
Cheers for Jean, Alex and the whole Playmaker guys for the awesome tools!!!
-
Hi Jean,
I think there is an error in the Unity documentation for RaycastHit2D.fraction which means the hit distance output gets incorrect results.
They seem to assume input distance = 1 in their writing.
In my experience you have to multiply the hit.fraction by the input distance to get an accurate result, even when using a normalized direction vector.
So it should be:
storeHitDistance.Value = hitInfo.fraction * rayLength;
-
Hi,
I think it's simply because my direction is normalized actually. I'll double check on this. Are you able to verify this properly with testing?
If the ray's direction vector is normalised then this value is simply the distance between the origin and the hit point
I am on that case, the direction I pass is normalized.
bye,
Jean
-
Yes, I know, the problem from what I can see is that that statement (which is from the Unity documentation) is actually wrong. In reality it seems to always pass the hit distance as a fraction of the total ray length (not as a fraction of the magnitude of the input direction as the documentation implies).
So if your input ray distance is 10, and the ray hits something at 5, fraction will return 0.5 even though your input direction vector is normalized. So you always have to multiply the result by the input distance to get an actual hit distance.
My suspicion is that the documentation may be based on some pre-release version of the function where there was no input distance (and distance was instead taken from the magnitude of the direction vector).
Right now your action always gives a "distance" result between 0...1 which is incorrect for any ray length /= 1.
-
This will make fixing the GetRayCastHit2dInfo action kind of difficult because it can't just store the RaycastHit2D - it also needs to store a reference to the input distance float separately so that can be factored into getting the distance.
-
Hi,
Ok, thanks for the clarfication, I'll run a proper test on this and update accordingly, I will add a new convenient float that will give the expected result to avoid the user having to do that fraction/raylenght dance...
also, always take the time to report documentation issues to Unity, It must be so hard for them to keep up with everything, so if you can pin point problems so that have it in their database will help get that done quicker. In their bug report, they have a section for Documentation.
bye,
Jean
-
I'm getting this error, and I didn't have it at all, before. How can I fix this?
NullReferenceException: Object reference not set to an instance of an object
PlayMakerUnity2d.OnLevelWasLoaded (Int32 level) (at Assets/Assets/PlayMaker Unity 2D/Scripts/PlayMakerUnity2d.cs:89)
NullReferenceException: Object reference not set to an instance of an object
PlayMakerUnity2DProxy.OnTriggerEnter2D (UnityEngine.Collider2D coll) (at Assets/Assets/PlayMaker Unity 2D/Components/PlayMakerUnity2DProxy.cs:159)
-
Hi,
You need that proxy on all your scenes, OR make it not destroyable on level load.
Is that the case?
bye,
Jean
-
Hi,
You need that proxy on all your scenes, OR make it not destroyable on level load.
Is that the case?
bye,
Jean
I don't really understand what that means. Are you talking about having them on every game object that uses 2d, or just the PlayMaker Unity 2D prefab? Either way it is halting my project and it's really frustrating. I wish I knew how to use this tool better.
-
The "PlayMaker Unity 2D" Prefab needs to exist exactly *once* in every scene.
The PlayMakerUnity2DProxy component needs to be added to every 2D gameobject that you want Playmaker to detect 2D collisions / triggers on.
Perhaps confusion might come from some of the wording as Jean has sometimes called the prefab component the Proxy (while in the package the Proxy is the component you must add to each gameobject).
-
The "PlayMaker Unity 2D" Prefab needs to exist exactly *once* in every scene.
The PlayMakerUnity2DProxy component needs to be added to every 2D gameobject that you want Playmaker to detect 2D collisions / triggers on.
Perhaps confusion might come from some of the wording as Jean has sometimes called the prefab component the Proxy (while in the package the Proxy is the component you must add to each gameobject).
Okay thanks. That certainly clears that up. The problem is that I'm getting the errors even after I've done all that. I'm using objects with children, and I'm only adding the proxy to parts of an object that use 2D triggers. Why would I still be getting these error messages? Does anyone know why?
-
hi,
Yeah, Thanks Dasbin for clarfiying :)
bye,
Jean
-
Jean..!
What happen of this?
"I am currently working on refactoring the Unity 2D game Sample from the asset store"
::)
-
hi,
Yeah, Thanks Dasbin for clarfiying :)
bye,
Jean
Why would I still be getting these error messages? Does anyone know why?
My question still remains: "Why would I still be getting these error messages? Does anyone know why?
NullReferenceException: Object reference not set to an instance of an object
PlayMakerUnity2d.OnLevelWasLoaded (Int32 level) (at Assets/Assets/PlayMaker Unity 2D/Scripts/PlayMakerUnity2d.cs:89)
NullReferenceException: Object reference not set to an instance of an object
PlayMakerUnity2DProxy.OnTriggerEnter2D (UnityEngine.Collider2D coll) (at Assets/Assets/PlayMaker Unity 2D/Components/PlayMakerUnity2DProxy.cs:159)
"
-
Looking through Jean's code in those sections, these are my best guesses:
- Your first error might be caused by not having the level in your Build Settings.
- The second error might be caused by not having a 2D Collider component attached to the other object (maybe just a Rigidbody2D with no collider?)
Just guesses.
If you still have trouble send me your scene packaged up and I will take a look.
-
Hi,
First, I'm sorry if it is the wrong topic to post this on, but I think there is a slight mistake on the wiki page.
I'm new to Unity and Playmaker, and when I wanted to set up Playmaker to work with Unity2D, I downloaded the Unity2D playmaker package and followed the instructions. But this got me confused:
Scene Setup
In order for Fsm to receive Physics 2d global event, a "PlayMaker Unity 2D" Prefab needs to be present at all time in the scene.
Use the Menu "PlayMaker/Addons/Unity 2D/Components/Add PlayMakerUnity2DProxy to Selection" to do so conveniently.
Game Object using Physics 2D Setup
In order for Fsm to receive Physics 2d global event, you need to drop a "PlayMakerUnity2DProxy" component on that GameObject. Then, any Fsm on that GameObject will be able to implement the global events "TRIGGER XXX 2D" and "COLLISION XXX 2D". The proxy is also used to store raycasting infos. Any other actions do not requires the proxy component, for example, AddForce2d works fine as is.
Use the Menu "PlayMaker/Addons/Unity 2D/Components/Add PlayMakerUnity2D to Scene" to do so conveniently.
I think you should swap these two lines. I know it's probably obvious for the average guy, but being a complete newbie (and a bit dumb), I really got confused with "PlayMakerUnity2DProxy" and "PlayMakerUnity2D"'s functions.
Other than that, I'd really like to thank you and this community for having built one of the best Unity Assets. It's so simple to understand yet so powerful.
-
Hi,
-- @xhidnoda: Doing to 2d animation demo in playmaker is something on the list, so it will be coming soon.
-- @Wledig: Could you rephrase how you would like this to be explained? cheers.
bye,
Jean
-
Well, when setting up the scene, you tell us to add a PlayMakerUnity2D to the scene but you wrote "Use the Menu "PlayMaker/Addons/Unity 2D/Components/Add PlayMakerUnity2DProxy to Selection" to do so conveniently."
And then you wrote that we need to drop a PlayMakerUnity2DProxy on a GameObject , but then you put: "Use the Menu "PlayMaker/Addons/Unity 2D/Components/Add PlayMakerUnity2D to Scene" to do so conveniently."
I just think it's the other way round. Well that's how I understood it anyways.
_____________
Ben, tu as marqué que pour que FSM reçoive les événements globaux concernant la physics 2D, on doit ajouter une prefab PlayMakerUnity2D à notre scène, mais tu dis que pour le faire il faut sélectionner dans le menu "Add PlayMakerUnity2DProxy to Selection".
Ensuite pour que le GameObject reçoive les événements globaux, tu dis qu'il faut y attacher PlayMakerUnity2DProxy, mais pour le faire il faut sélectionner dans le menu "PlayMaker/Addons/Unity 2D/Components/Add PlayMakerUnity2D to Scene".
Je pense juste que tu voulais dire l'inverse. Certaines personnes (un peu bêtes comme moi) pourraient croire qu'il faut ajouter le Proxy à la scène et le PlayMakerUnity2D à un GameObject. En gros inverser les deux lignes en gras. Non?
Sorry if I didn't express myself properly, that's no big deal anyways.
-
Salut,
pardon, j'avais pas compris... c'est fait :)
bye,
Jean
-
Hi,
I have been using the 2D physics in a 3d environment (2.5d game) and so far no problems. But i did see that error telling me to add the 2dproxy to the scene. Is it required if i will not be playing animations on anything 2d? I'm making a 3.5d game and the 2d physics are much better performance wise so that was my choice.
-
It's nothing to do with animations - it's required if you want your 2D physics objects to receive Trigger and Collision events via Playmaker. That's it.
-
But can't find Hinge Joint 2d or other 2d property?
-
Hi,
you have to use "set property" or "get property" actions, and then you can point to the hinge2d component and access all it's public variables.
Have you tried that?
bye,
Jean
-
very thanks for answer, but there's no property of hinge2d in "set property" or "get property" yet:
(http://v1.freep.cn/3tb_140512224732fswd512293.jpg)
or can i find the hinge2d component in other place? :-[
thanks very much!
Hi,
you have to use "set property" or "get property" actions, and then you can point to the hinge2d component and access all it's public variables.
Have you tried that?
bye,
Jean
-
Hi,
can you do a screenshot of the action without the popup so that I can see if you are targeting properly the hinge. to me it still is that you don't rag it properly ( drag visually the hinge component bar itself, nothing else.
bye,
Jean
-
after the release of version 5.2.3 Unity , PlayMaker action collider2D_enter I do not function correctly, who knows what problems? temporarily rolled back the project to version Unity 5.2.2
-
Hi,
Investigating...
Bye,
Jean
-
Hi,
I can't find any errors, please double check the following:
-- you have the "PlayMaker Unity 2D" prefab instanciated in your scene
-- you have a "PlayMaker Unity 2D proxy" component attached to your GameObject you want to receive the collision event from.
-- you have a rigidbody 2d and a collider 2d properly setup on both objects colliding.
Let me know how it goes,
Bye,
Jean