mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 09:35:34 +00:00
Mapping and direction code
This commit is contained in:
parent
c1f83736f0
commit
944249d408
26 changed files with 1453 additions and 536 deletions
|
|
@ -126,20 +126,36 @@ public partial class Bullet3D : Area3D, IBullet
|
|||
|
||||
private Vector3 MakeRotationFromDirection(Vector2 direction)
|
||||
{
|
||||
// Rotate input by -45 degrees to counter camera isometry
|
||||
float cos = Mathf.Cos(-Mathf.Pi / 4f);
|
||||
float sin = Mathf.Sin(-Mathf.Pi / 4f);
|
||||
// atan2 gives angle in radians around Z
|
||||
float zRotation2 = Mathf.Atan2(-direction.Y, direction.X) + Mathf.Pi;
|
||||
|
||||
Vector2 rotatedDir = new Vector2(
|
||||
direction.X * cos - direction.Y * sin,
|
||||
direction.X * sin + direction.Y * cos
|
||||
// Apply correction for your sprite's local forward axis
|
||||
zRotation2 += Mathf.DegToRad(45f); // tweak to +45 or -45 as needed
|
||||
|
||||
return new Vector3(
|
||||
Mathf.DegToRad(-45f), // X tilt (to match camera)
|
||||
Mathf.DegToRad(45f), // Y tilt (to match camera)
|
||||
zRotation2 // Facing direction
|
||||
);
|
||||
|
||||
//float zRotation = Mathf.Atan2(rotatedDir.Y, rotatedDir.X)/* - Mathf.Pi / 2f*/;
|
||||
|
||||
float zRotation = Mathf.Atan2(-rotatedDir.Y, rotatedDir.X) + Mathf.Pi;
|
||||
|
||||
return MakeRotationVectorRad(zRotation);
|
||||
|
||||
// var rotatedVector = direction.Rotated(Mathf.DegToRad(-45));
|
||||
// var asrt = Vector2.ang
|
||||
// return MakeRotationVectorRad(zRotation);
|
||||
|
||||
// Rotate input by -45 degrees to counter camera isometry
|
||||
// float cos = Mathf.Cos(-Mathf.Pi / 4f);
|
||||
// float sin = Mathf.Sin(-Mathf.Pi / 4f);
|
||||
//
|
||||
// Vector2 rotatedDir = new Vector2(
|
||||
// direction.X * cos - direction.Y * sin,
|
||||
// direction.X * sin + direction.Y * cos
|
||||
// );
|
||||
//
|
||||
// //float zRotation = Mathf.Atan2(rotatedDir.Y, rotatedDir.X)/* - Mathf.Pi / 2f*/;
|
||||
//
|
||||
// float zRotation = Mathf.Atan2(-rotatedDir.Y, rotatedDir.X) + Mathf.Pi;
|
||||
// var zRotationDegrees = Mathf.RadToDeg(zRotation);
|
||||
// return MakeRotationVectorRad(zRotation);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue