Author Topic: Alternative to getEyeVector(); that ignores freelooking?  (Read 1745 times)

I don't understand what's wrong with

Code: [Select]
function Player::getLOSPoint(%this, %mask, %dist)
{
    %start = %this.getEyePoint();
    %image = %this.getMountedImage(0);
    if(isObject(%image))
        %this.unMountImage(0);
    %vector = %this.getMuzzleVector(0);
    if(isObject(%image))
        %this.mountImage(%image, 0);
    %end = vectorAdd(%start, vectorScale(%vector, %dist));
    %ray = containerRayCast(%start, %end, %mask, %this);
    if(%ray)
        return getWords(%ray, 1, 3);
    return %end;
}
« Last Edit: February 17, 2014, 11:11:54 AM by $trinick »

The point is that the vector it fires the raycast along is the normalized vector of the difference between the LOS point and the muzzle point. Using the muzzle vector to calculate the LOS point would just result in firing it along the muzzle vector, which is not intended (standing inside a wall would cause rays to go through it). If you use the eye point, the ray would travel back to hit the wall.

Then fire from the eye point using the muzzle vector? As I've said multiple times, getMuzzleVector (without a weapon equipped) and getEyeVector return the same exact value, except getMuzzleVector does not account for freelook.
« Last Edit: February 17, 2014, 11:13:28 AM by $trinick »

Firing from the eye point would yield a completely wrong result when it comes to being blocked by geometry, shot tracers and the like. All that's needed in this context is appropriately scaling the X and Y values of the forward vector by the Z value of the eye vector. Just doing so plainly (* (1 - mAbs(z))) yields highly inaccurate results when gradually looking up and down.

Firing from the eye point would yield a completely wrong result when it comes to being blocked by geometry
If you use the eye point, the ray would travel back to hit the wall.


What I meant by that former quote is your weapon being blocked on the right side of the screen but you still being able to see a player.

shot tracers and the like

So again, fire from eyepoint instead of muzzle point. OP's question is literally "Alternative to getEyeVector(); that ignores freelooking?" and getMuzzleVector does exactly that. You can fire from your eye, hand, foot, richard, or chest, whatever suits you, but getMuzzleVector will get you the angle you're facing including Z.

So again, fire from eyepoint instead of muzzle point. OP's question is literally "Alternative to getEyeVector(); that ignores freelooking?" and getMuzzleVector does exactly that. You can fire from your eye, hand, foot, richard, or chest, whatever suits you, but getMuzzleVector will get you the angle you're facing including Z.
Trinick.
GetMuzzleVector(0); doesn't work right with getLOSpoint which can be considered an obstruction check.
IF I don't do any sort of obstruction check the raycast will go through walls and everything you're too close to, meaning that the ray always fires from muzzle point.
So if my gun's muzzle is beyond the wall I'm trying to shoot at it will wallhack instead.
Stop repeating yourself all the damn time if you don't understand the actual issue.



Once again, with no weapon equipped, getMuzzleVector(0) always returns the same value as getEyeVector(). It does not matter if you are standing very close to a wall. It doesn't matter if you're in a wall. You are confusing getMuzzleVector with getMuzzlePoint. The muzzle vector is completely irrelevant to the point you shoot from.

You're not understanding the issue at all. When facing a wall, the target vector of the raycast should go backwards, toward the player, which is achieved by firing the way toward the LOS point instead of along the muzzle vector. Calculating the LOS point with the muzzle vector makes no sense.

When a weapon isn't equipped the muzzle vector and the eye vector are the exact same thing. Therefor it makes perfect sense to use it in place of getEyeVector() if you do not want to take account for freelooking. I'm not gonna sit here and force a solution down your throat anymore, but I'm telling you that getMuzzleVector is a perfect substitution for getEyeVector when a weapon is not equipped and when freelooking is not desired.

A weapon would always be equipped, the entire point of this is to be used with a raycasting weapons system.

When a weapon isn't equipped the muzzle vector and the eye vector are the exact same thing. Therefor it makes perfect sense to use it in place of getEyeVector() if you do not want to take account for freelooking. I'm not gonna sit here and force a solution down your throat anymore, but I'm telling you that getMuzzleVector is a perfect substitution for getEyeVector when a weapon is not equipped and when freelooking is not desired.
The fact is this is not the loving solution.
Stop forcing something that doesn't even work in this situation down our goddamn throats.