Playmaker Forum
PlayMaker Updates & Downloads => Share New Actions => Topic started by: Thore on September 25, 2018, 04:15:35 PM
-
SetRigidBodyType2D
The action allows you to change the body type and simulated parameters in a Rigidbody 2D (I was surprised that no acion exists, or I overlooked it).
Purpose
I needed the action because I have physics objects in the scene that are tempoarily bound to the character, for which these parameters need to be changed temporarily. But it's probably an esoteric need.
Small Caveat
In a perfect action, the body type drop down's default would be "don't change". However, it's populated by Unity enums and I don't know how to add a nice extra option in there. However, that's cosmetics.
My simple workaround is a bool that asks if you want to leave body type alone, and only change the simulated property (which was what I needed in the end). Perhaps a more elegant way would be to split the action into two, for each separate setting.
I also read in documentation that these changes are best in FixedUpdate. But when I plug them there, they show no effect. It's now a standard OnEnter affair, and works.
As Usual
Anyone can of course use this and modify it. Someone with access can also upload it to Ecosystem, too (though beware, I am not a coder, please doublecheck). ;)
-
Hi.
I have updated the action so it works the way you wanted it to work :)
As you are not updating, but only set this once.
fixedupdate is not needed.
and also added to the Ecosystem
-
Thanks a lot, and especially for the "cosmetic" fix. ;)
-
Hi,
NO problem, did you check out the script and understand what i did?
-
I did, of course, and it also works in my setting. I was on a similar track, at first, but had a syntax bug in there somewhere (hence why I'm using Playmaker in the first place) and then gave up on that idea, thinking it's probably some convoluted trick I didn't know. Didn't keep the broken version, alas, cannot check what exactly I did wrong.
-
Hi.
Actually i had to google myself to see how i could use an enum with an enum :)
There are 2 ways, one by using the index (which i am doing in the action and that's why 'do nothing' is set last)
The other way is more complex by using the name.
-
Hi djaydino,
The action works nicely, however I found some improvements:
[ActionCategory(ActionCategory.Physics2D)]
needs the 2D to be listed correctly.
ComponentAction<Rigidbody2D>
also should have the 2D attached, too. Component action is potentially superfluous if it worked before.
simulated = true;
rigidbody2d are simulated (true) by default.
-
Hi,
Cool, Kurt can you put that on the ecosystem? thanks.
Bye,
Jean
-
Hi.
It is already on the Ecosystem, but have updated the Category.
ComponentAction<Rigidbody2D>
The line above is already good on the Ecosystem version.
Due to that it is already on the Ecosystem i think it is best to leave the default as is.