I want to move only the Z axis at the midpoint of the 3D parabola connecting the two points.

Asked 2 years ago, Updated 2 years ago, 329 views

We draw a 3D parabola connecting the two points.

Vector3_controlPoint=new Vector3(0,0,-50);
var control=(_trans1.position+_trans2.position)/2+_controlPoint;
verticalPoints=_middlePoints+2;
List<Vector3>l_list=new List<Vector3>();
l_list.Add(_trans1.position);
for (inti=1;i<=_middlePoints;i++)
{
    start=(float)i/(float)(totalPoints-1);
    Vector3_pos1 = Vector3.Lerp(_trans1.position, control, t);
    // Interpolate along line S1:S1 = end-control;
    Vector3_pos2 = Vector3.Lerp(control,_trans2.position,t);
    // Interpolate along line S2—Q1-Q0
    Vector3_pos = Vector3.Lerp(Q0,Q1,t);
    l_list.Add(mpos);
}
l_list.Add(_trans2.position);

"I have changed the value of the intermediate point ""control"" from the center, but
" It is not a 90° line to the ground, but a tilted line.

var control=(_trans1.position+_trans2.position)*0.85f+_controlPoint;

I'm aiming for a line like a fishing rod.
Where should I correct this code?

Thank you for your cooperation.

unity3d

2022-09-30 21:54

1 Answers

The control calculation method is incorrect.If you do the following, you will find the correct midpoint.

var control=Vector3.Lerp(_trans1.position,_trans2.position, 0.85f)+_controlPoint;


2022-09-30 21:54

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.