#Tank Steering Thread

1 messages ยท Page 1 of 1 (latest)

long heron
#

I think we should do this in the thread.

merry bramble
#

I just need to know what this means

2 points in 3d space is not enough information to orient it.

There needs to be more info.

You want to stand at pointA and 'lookAt' pointB?

Well... long explanation ahead:

tldr;

You're creating a rotation that looks in the direction of 'forward' while standing in an orientation so that up is the direction of 'up'.

Your 'forward' should be 'pointB - pointA', and up is most likely Vector3.up or <0,1,0> 
long heron
#

Yes, and your SignedAngle using Vector3.up, correct?

merry bramble
#

Yes

long heron
#

You gotta know which plane the angle is based on to calculate angle in 3D

#

and you're doing on XZ plane so use the normal of that plane which is Vector3.up

merry bramble
#

Here's script again simplified
A = driver.transmission.transform
B = SteeringAngle

Vector3 C = B - A;
float D = Vector3.SignedAngle(-A.forward, C, -Vector3.up);
float angle = Mathf.DeltaAngle(D, A.eulerAngles.y);
int angleNormal = angle > 0 ? -1 : 1;
long heron
#

Well.. you don't need DeltaAngle

#

A's rotation is already considered because you're getting angle from A.forward

#

What is the real problem

merry bramble
#

It supposed to face the pink line

long heron
#

Which means B and A has same x

#

But pink line is not parallel with world z axis

#

Therefore pink line is not drawing from A to B

merry bramble
#

OMG IT WORKS NOW

#

INDEX ERROR

long heron
#

Great ๐Ÿ™‚

merry bramble
#

I WAS USING THE FIRST NODE

#

NOT THE SECOND ONE

#

OMG

long heron
#

Ah yeah I remember navigation path was like that

merry bramble
#

There is some jitteriness but it can fixed.

long heron
#

You can do it ๐Ÿ™‚