Re: moving players in angles like in FPS type games

@Kianoosh: your method is slightly wrong. As well as Samtupyone, if you was just rewriting his code with better rounding, it isn't your fault.
What is problem here is, that Samtupy haven't included any connection between x, y and z axis. Imagine you stand at 0;0;0 and are facing 0 degrees and 90 vertical, thus looking straight up right?
Now, applying this method, z will be raised to 1, because you're looking upward. But y will also be raised by 1, because your direction is 0 degrees and your vertical angle does not influence horizontal movement in these formulas.
So instead of ending on 0;0;1, one point up from the first position, you end on 0;1;1, 45 degrees vertically from your first position, what is probably not what you want.

I have designed my own formulas to solve this problem, because I needed 3D movement in Blindcraft. I have posted my code on this forum some time ago. Now, here is its edited, nice version for C++, which I'm currently using:

BgtVector move_3d(double x, double y, double z, double angle, double zAngle, double distance=1.0)
{
BgtVector r;
double length=distance*cos(zAngle*pi/180);
r.x=x+length*sin(angle*pi/180);
r.y=y+length*cos(angle*pi/180);
r.z=z+distance*sin(zAngle*pi/180);

return r;
}

Simple and straight-forward I think, just replace BgtVector with vector and it should work in bgt as well.
Just one thing to add, this method counts with x axis going from the left to right, y from behind to front, z from bottom to the sky and horizontal angle 0 representing north with 90 east, 180 south etc. and vertical angle 0 being normal angle, 90 straight up, 180 behind etc.

Best regards

Rastislav

-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : cw via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : kianoosh via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : redfox via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : cw via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : kianoosh via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Rastislav Kiss via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : cw via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : cw via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : kianoosh via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Rastislav Kiss via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : kianoosh via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Rastislav Kiss via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector

Reply via email to