Vector to Rotator

Discussions about Coding and Scripting
Post Reply
User avatar
Barbie
Godlike
Posts: 2802
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Vector to Rotator

Post by Barbie »

<UPDATE>
Found the solution: Rotator(M - P)
(So easy... :lol: For results see map "MH-Beginning_{HoF}" on servers using my MapPatcher)
</UPDATE>
I want to spawn some class'U' at location P(x1/y1/z1), give them the mesh of a ScriptedPawn and want to rotate them in that way that they are looking to a certain point M(x0/y0/z0). So the normal vector V should be V = M - P. How can I translate that vector into the rotation?
Attachments
Vectors.png
Vectors.png (5.66 KiB) Viewed 442 times
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
TexasGtar
Adept
Posts: 295
Joined: Sun Feb 16, 2020 5:52 pm

Re: Vector to Rotator

Post by TexasGtar »

Who says girls aren't good at math?
I don't know anything about coding anything. I'm glad you figured it out.
Good job!
User avatar
sektor2111
Godlike
Posts: 6410
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Vector to Rotator

Post by sektor2111 »

Code: Select all

function DoSayReach()
{
	if ( P != None ) //P is PlayerPawn owner and paths seeker
	{
		if ( bWorking )
		{
			P.ClearProgressMessages();
			P.SetProgressMessage("Destination is Reachable!",1);
			clMsg.R=255;
			clMsg.G=128;
			clMsg.B=0;
			P.SetProgressColor(clMsg,1);
			P.SetProgressTime(3);
			DoResetChilds();
			NewRot = Rotator(P.Destination - P.Location); //Occurs if target is reachable because you might fail to see it
			P.ClientSetLocation(P.Location,NewRot);
			bWorking=False;
		}
	}
}
User avatar
Barbie
Godlike
Posts: 2802
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Vector to Rotator

Post by Barbie »

Condense it to

Code: Select all

P.ClientSetLocation(P.Location, Rotator(P.Destination - P.Location);
8)
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
sektor2111
Godlike
Posts: 6410
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Vector to Rotator

Post by sektor2111 »

Umm... yep, I'll reduce resources data this way and removing new variable...

Edit: Now I want to learn and keep in my head a free trace of certain actor in direction where actor is facing - something like 300 UU in front of my eyes.

Purpose: Testing Playerstarts if are facing a wall - the crap kills people at RocketLauncher arenas without real spawnkill protections.
The plan is reporting these without checking each PlayerStart wasting a lot of time.
Buggie
Godlike
Posts: 2734
Joined: Sat Mar 21, 2020 5:32 am

Re: Vector to Rotator

Post by Buggie »

sektor2111 wrote: Sun Sep 27, 2020 12:00 pm I want to learn and keep in my head a free trace of certain actor in direction where actor is facing - something like 300 UU in front of my eyes.
Desired point:

Code: Select all

vector Target;

Target = PlayerStart.Location + vector(PlayerStart.Rotation)*300;
Now check trace from PlayerStart.Location to Target.
User avatar
sektor2111
Godlike
Posts: 6410
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Vector to Rotator

Post by sektor2111 »

I see...
I wrote this a few minutes ago... but I'll look at your solution - it looks more simple.

Code: Select all

function bool WallFacing(Actor A) //Inspired from Mercenary
{
	local rotator AdjRot;
	local vector EndTrace, RotDir;
	local bool bFreeDir;

	if ( A == None || A.bDeleteMe ) //Should log this funky situation ?
		return False;

	AdjRot = A.Rotation;
	RotDir = vector(AdjRot);
	EndTrace = A.Location + 280 * RotDir;
	bFreeDir = A.FastTrace(EndTrace,A.Location);

	return !bFreeDir;
}
Post Reply