Playmaker Forum

PlayMaker Updates & Downloads => Share New Actions => Topic started by: holyfingers on September 18, 2015, 11:06:31 AM

Title: Draw Bézier Curve Action
Post by: holyfingers on September 18, 2015, 11:06:31 AM
Hi there,

Couldn't find an action for drawing a curve anywhere so thought I'd try and put one together...

(http://i.imgur.com/wLjHwQn.gif)

It's based on the existing Draw Line action from here: http://hutonggames.com/playmakerforum/index.php?topic=3943.0 (http://hutonggames.com/playmakerforum/index.php?topic=3943.0) though it doesn't have quite as many options, I might add them in later on.

The code for defining the curve comes from here: https://en.wikibooks.org/wiki/Cg_Programming/Unity/B%C3%A9zier_Curves (https://en.wikibooks.org/wiki/Cg_Programming/Unity/B%C3%A9zier_Curves)

First attempt at making a custom action and I'm not much of a coder so let me know if there's anything that needs fixed/changed!

Cheers,

Nick
Title: Re: Draw Bézier Curve Action
Post by: dudebxl on September 18, 2015, 02:03:23 PM
cool  ;D
Title: Re: Draw Bézier Curve Action
Post by: boragungor on September 18, 2015, 03:07:52 PM
Thanks  :)
Title: Re: Draw Bézier Curve Action
Post by: holyfingers on September 20, 2015, 11:21:05 AM
Managed to get the Spline code from that page working as well, so you can now define how many points you want to use. Not quite as straightforward as before, it needs at least 5 control points and your Start point and End point need to occupy the first two and last two slots for the spline to reach the ends.

(http://i.imgur.com/DqkAeeo.png?2)

Could be a lot tidier, it would be nice to be able to set the Start and End points and just use the compound array for the Middle ones for example. I also couldn't find a way to use just one input per array item hence the empty Label strings. It seems to be working pretty well though so I'd thought I'd share it as is.

Again, let me know if there are any issues I've missed!

Cheers,

Nick
Title: Re: Draw Bézier Curve Action
Post by: Lane on September 20, 2015, 11:29:32 AM
Looks cool!

I haven't checked the code out yet but since you're still tinkering with it I thought I would drop Jasper Flick's Bezier tutorial (http://catlikecoding.com/unity/tutorials/curves-and-splines/) since its got some nifty solutions in it. Might help tidy things up for you. =)
Title: Re: Draw Bézier Curve Action
Post by: holyfingers on September 20, 2015, 11:36:44 AM
Oh wow that looks amazing! :D Covers placing objects along curves as well which would be really handy!

Cheers Lane! 
Title: Re: Draw Bézier Curve Action
Post by: elvis75k on September 20, 2015, 05:08:20 PM
Great, thank for sharing.
Title: Re: Draw Bézier Curve Action
Post by: play_edu on September 20, 2015, 11:55:23 PM
 ::) ::) ::)
Title: Re: Draw Bézier Curve Action
Post by: jeanfabre on September 21, 2015, 07:19:20 AM
Hi,

 Yeah, these are great actions!

I took the opportunity here to make a video showing how to publish your work on the Ecosystem via the snipt website. It's free and it allows you to effortlessy distribute your work to PlayMaker user very easily,

If you want to do this for your actions, let me know and I Can delete the drawcurve snipt from my account. But no worries if you don't feel like it, it's just a suggestions. I'll add them myself otherwise, it's ok.

Video (https://youtu.be/VQUsFVWmmUo)

 Bye,

 Jean
Title: Re: Draw Bézier Curve Action
Post by: holyfingers on September 21, 2015, 07:57:16 AM
Hey Jean,

Glad you like them! :D

Just signed up for a free Snipt account there now, out of curiosity how does Ecosystem handle updates? Is there anything to be aware of if I put the actions up and then make some changes to them later on?

Cheers,

Nick
Title: Re: Draw Bézier Curve Action
Post by: jeanfabre on September 21, 2015, 09:29:22 AM
Hi,

 very good! thanks :)

 Right now there isn't any update system per say. you can update the code, but the user will need to be made aware of updates.

 the ecosystem is certainly going to implement such a feature in the comin month, but first I need to get out of the door several pending feature.

 I would suggest simply tweet about your updates, and post on the forum on the related thread.

 Bye,

 Jean
Title: Re: Draw Bézier Curve Action
Post by: holyfingers on September 21, 2015, 09:43:24 AM
Thanks Jean!

Had to just fix the DrawSpline action there quickly because of a silly copy/paste error, the version here and on Ecosystem both seem to be working now though!

Cheers,

Nick
Title: Re: Draw Bézier Curve Action
Post by: jeanfabre on September 21, 2015, 09:47:12 AM
Hi,

 Yeah, it's part of the process, no one will hold you liable, script needs to evolve, and it's ok. If your action doesn't work, people will come back to you, don't worry :)

Update system will come soon, I know it will be a big plus on comfort for both publishers and consumers. But I want to get it right, and it's tricky without a proper back end, here I am only the middle mand between snipt/github and Unity, with update awareness, it's a different deal all together :) I am thinking of opening a channel of communication right within the ecosystem browser so that publishers can register their changes. The other way is a project scanner that would scan and tell you what can be updated. that's likely coming first.



 Bye,

 Jean
Title: Re: Draw Bézier Curve Action
Post by: holyfingers on March 11, 2016, 11:27:53 AM
I've just updated these actions on Ecosystem/Snipt, they both now include a toggle for destroying the line rendering object on exiting the state...

*EDIT: Removed Snipt links*

Cheers,

Nick
Title: Re: Draw Bézier Curve Action
Post by: holyfingers on October 09, 2017, 05:21:53 AM
Hey there, updated the two scripts to remove errors in Unity 2017.1, haven't got round to putting them back up on Ecosystem yet since Snipt dissappeared.

Also removed the Snipt links from previous post as they were redirecting to an unrelated Github repo!?

Updated Draw Curve and Draw Spline actions attached...
Title: Re: Draw Bézier Curve Action
Post by: jeanfabre on October 11, 2017, 04:05:46 AM
Hi,

 thanks :) on the Ecosystem now!

 Bye,

 Jean
Title: Re: Draw Bézier Curve Action
Post by: Groo Gadgets on October 11, 2017, 08:27:29 AM
Very nice! Thanks for the share!   ;D
Title: Re: Draw Bézier Curve Action
Post by: holyfingers on November 07, 2017, 09:40:30 AM
Another quick update, you can now specify a GameObject variable for the created lineRenderer...

Cheers,

Nick
Title: Re: Draw Bézier Curve Action
Post by: omgitstri on November 07, 2017, 01:58:18 PM
This is great! Thank you!
Title: Re: Draw Bézier Curve Action
Post by: craigz on September 01, 2019, 01:37:57 AM
Just wanted to bump on this :D anyone else having issues with 2019 and these actions? Eeee! :D

Thanks,
craigz
Title: Re: Draw Bézier Curve Action
Post by: holyfingers on September 01, 2019, 08:12:03 AM
Hey, it's been a long time since I looked at these but doing a quick test here using the scripts linked above, Unity 2019.1.14f1 and Playmaker 1.9.0.p18 and everything seems to be behaving? What kind of errors are you seeing?
Title: Re: Draw Bézier Curve Action
Post by: Broken Stylus on September 02, 2019, 05:45:38 AM
Woah! That's a brutally good action, can't believe I missed it.
Any idea on how to create a progressive blur to smoothen the edges though?
Title: Re: Draw Bézier Curve Action
Post by: jeanfabre on September 13, 2019, 02:02:47 AM
Hi,

 Don't forget these actions are on the Ecosystem.

Bye,

 Jean
Title: Re: Draw Bézier Curve Action
Post by: jeanfabre on September 13, 2019, 02:06:24 AM
Hi,

 as for the smoothness and anti aliasing, I think it's to do with using a graphic with alpha edges, but I never got good results myself, I resort to post processing antialiasing to solve the problem.

Bye,

 Jean
Title: Re: Draw Bézier Curve Action
Post by: Krillan87 on February 03, 2021, 04:13:34 AM
Hi!

I've been playing around with these two actions but I can not make them work at all. I do not even see a line. Do I need to add a specific component to a game object or something? Like a line renderer or a Sprite shape controller?

I seems like I am missing something basic here...
Title: Re: Draw Bézier Curve Action
Post by: Krillan87 on February 03, 2021, 06:16:58 AM
Hi!

I've been playing around with these two actions but I can not make them work at all. I do not even see a line. Do I need to add a specific component to a game object or something? Like a line renderer or a Sprite shape controller?

I seems like I am missing something basic here...

Okey I found the issue when I took a closer look at the original "Draw Line" action. With these custom actions you can not set the Sorting layer on the action, so the draw lines will automatically be on Default layer (with in my 2d game will not work out). Would be nice to update the action to include that we can define what sorting layer the Draw Curve should happen on!

Thanks!
Title: Re: Draw Bézier Curve Action
Post by: Broken Stylus on February 03, 2021, 11:45:19 AM
Perhaps using this (https://docs.unity3d.com/ScriptReference/Renderer-sortingOrder.html)?