PitchTo()

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: PitchTo()

Re: PitchTo()

by Major Cooke » Wed May 20, 2020 8:18 am

The function itself has an absolute parameter. It's false by default already, which makes it portal aware.

Re: PitchTo()

by SanyaWaffles » Mon May 18, 2020 9:32 pm

I'm having trouble figuring out how to convert Gutawer's code to LevelLocals.SphericalCoords. I'd like to be able to account for portals.

Re: PitchTo()

by Rachael » Mon May 18, 2020 9:09 pm

It looks like it was already added, just no one closed the thread.

Re: PitchTo()

by Matt » Mon May 18, 2020 8:15 pm

Would it even make a performance difference anymore nowadays?

Re: PitchTo()

by Accensus » Sun May 17, 2020 4:50 am

Bumperino. Will this get added natively or will it remain DIY?

Re: PitchTo()

by Apeirogon » Thu Aug 30, 2018 3:30 am

Before try to make something like this I wonder does distance(2/3)d more performance wise than cos/sin(arctan(number) )?

Re: PitchTo()

by Graf Zahl » Tue Aug 21, 2018 12:23 am

I'd rather do this natively for performance reasons.

Re: PitchTo()

by argv » Mon Aug 20, 2018 6:40 pm

I've submitted pull request #553 which, if merged, will do what you need. See forum post for an example.

Re: PitchTo()

by Matt » Tue Mar 13, 2018 12:05 am

That is correct.

Re: PitchTo()

by Major Cooke » Mon Mar 12, 2018 3:59 pm

He's trying to have this be made done on the engine side to reduce calculations on the VM side, correct me if I'm wrong.

Re: PitchTo()

by Gutawer » Mon Mar 12, 2018 3:04 pm

You can do this via something like this:

Code: Select all

Vector3 dirTo = vec3To(other).unit();
double angleTo = atan2(dirTo.y, dirTo.x);
double pitchTo = -asin(dirTo.z);
You can of course take out the angleTo line if it's unnecessary.

Re: PitchTo()

by Matt » Mon Mar 12, 2018 1:49 pm

Major Cooke wrote:Anyway, Matt, one thing you could do in the mean time is use A_Face and set the angle limit to something non-zero.
That's pretty much what I'm doing now - storing a backup pitch and angle, calling A_Face, recording the new pitch and resetting the pitch and angle.

Re: PitchTo()

by Apeirogon » Fri Mar 09, 2018 7:33 am

All defined in zscript, inside gzdoom pack, hitscan enemy use "aim line attack" to get slope/pitch to it target, not arctangent of distance and positions.
So, I think, this is the quickest way to get pitch/slope to some actor.

Re: PitchTo()

by Major Cooke » Thu Mar 08, 2018 5:02 pm

...What was the point of your post?

Anyway, Matt, one thing you could do in the mean time is use A_Face and set the angle limit to something non-zero.

Re: PitchTo()

by Apeirogon » Thu Mar 08, 2018 4:24 pm

Matt wrote:atan( (pos.z-other.pos.z) / distance2d(other))
"Why walk, if you could ride astride?" Silt Strider chasseur quote

Code: Select all

extend class Actor
{
	void A_PosAttack()
	{
		if (target)
		{
			A_FaceTarget();
			double ang = angle;
			double slope = AimLineAttack(ang, MISSILERANGE);
			A_PlaySound("grunt/attack", CHAN_WEAPON);
			ang  += Random2[PosAttack]() * (22.5/256);
			int damage = Random[PosAttack](1, 5) * 3;
			LineAttack(ang, MISSILERANGE, slope, damage, "Hitscan", "Bulletpuff");
		}
	}

Top