- Home /
Bezier curve confusion on 2 points
I was looking at this http://docs.unity3d.com/ScriptReference/Handles.DrawBezier.html in the docs for how to draw a bezier curve but I am confused.. How do I get it to just be an upward arc/curve between to different game Objects?
Answer by richyrich · Dec 15, 2014 at 12:21 AM
The link you have given is for Bezier in the scene view, not game.
The link below is what you want. It has loads of examples of the different Bezier flavours and all wrapped in a Unity project. Enjoy.
http://devmag.org.za/2011/04/05/bzier-curves-a-tutorial/
However, for your purposes, you might not actually need a Bezier. Instead, Vector3.Slerp might do all you need (Spherical Linear interpolation) to figure out the points spherically between two points (Vectors)
well... I do use it in game with function OnDrawGizmos(){ to render it like any other line. The thing is I am confused as to why it will not just allow the curve to be between two chosen points ins$$anonymous$$d of the world point zero to a target, ie
var width : float = HandleUtility.GetHandleSize(target.transform.position) * foo;
Handles.DrawBezier(target.transform.position, transform.position, transform.up, -transform.up, Color.red, null, width);
Here the line starts and ends at the transforms, but the center directs to the world point zero. I trying to cut that out so it will be a regular arc
hmm... are you sure that the target is not a child of an object at Vector3.zero? :/
I do use it in game with function OnDrawGizmos(){
In Unity there are two tabs 'Scene' and 'Game'. OnDrawGizmos is only for editor/scene. When you build your game, the player will not see gizmos.
Hmm, ok. Forgetting what this is for, to get you an arc as required...
From:
var width : float = HandleUtility.GetHandleSize(target.transform.position) * foo;
Handles.DrawBezier(target.transform.position, transform.position, transform.up, -transform.up, Color.red, null, width);
To:
var width : float = HandleUtility.GetHandleSize(target.transform.position) * foo;
Handles.DrawBezier(target.transform.position, transform.position, transform.position + Vector3.up * 10f, p1.transform.position + Vector3.up * width, Color.red, null, width);
Your answer
Follow this Question
Related Questions
Controlling the curvature of a Bézier curve 2 Answers
Which Variables control the shape of a Beizer Curve? 1 Answer
iTween, HOTween, Spline Controller and Others 1 Answer
How can I make a Lerp move in an arc instead of a straight line? 2 Answers
[Vectrosity] 3d bezier curve not generated correctly 1 Answer