PitchTo()

Remember, just because you request it, that doesn't mean you'll get it.

Moderator: Developers

PitchTo()

Postby Matt » Wed Mar 07, 2018 7:24 pm

This could be done by other means, but it would be nice not to have to do a distance calculation and arctangent lookup in the VM.
User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: PitchTo()

Postby Major Cooke » Wed Mar 07, 2018 7:56 pm

Specifically? Towards another actor or towards a point?
User avatar
Major Cooke
Slaughterer of Sewers
 
Joined: 28 Jan 2007
Discord: Major Cooke#0846

Re: PitchTo()

Postby Matt » Wed Mar 07, 2018 8:16 pm

AngleTo() is towards an actor but arbitrary point would be nice! (and preferable)

It really is just atan( (pos.z-other.pos.z) / distance2d(other)), but now that I type this out it does seem like quite a few VM instructions.
User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: PitchTo()

Postby Apeirogon » Thu Mar 08, 2018 5: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 allExpand view
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");
      }
   }
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: PitchTo()

Postby Major Cooke » Thu Mar 08, 2018 6: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.
User avatar
Major Cooke
Slaughterer of Sewers
 
Joined: 28 Jan 2007
Discord: Major Cooke#0846

Re: PitchTo()

Postby Apeirogon » Fri Mar 09, 2018 8: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.
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: PitchTo()

Postby Matt » Mon Mar 12, 2018 2: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.
User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: PitchTo()

Postby Gutawer » Mon Mar 12, 2018 4:04 pm

You can do this via something like this:
Code: Select allExpand view
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.
User avatar
Gutawer
 
 
 
Joined: 16 Apr 2016
Discord: Gutawer#3431

Re: PitchTo()

Postby Major Cooke » Mon Mar 12, 2018 4: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.
User avatar
Major Cooke
Slaughterer of Sewers
 
Joined: 28 Jan 2007
Discord: Major Cooke#0846

Re: PitchTo()

Postby Matt » Tue Mar 13, 2018 1:05 am

That is correct.
User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia


Return to Feature Suggestions

Who is online

Users browsing this forum: No registered users and 1 guest