Viewpos and mapping
Moderator: Core Staff
Viewpos and mapping
Hey guys, i am wondering if there is a much better way to get sizes of walls, etc rather than using viewpos. I am trying to recreate a Sp map and wondering if there is a different way. I just don't feel im doing it right with viewpos. Should i be taking into consideration player sizes when using it ? any help is appreciated, thanks.
Re: Viewpos and mapping
I guess you could do it with mod. Do mods work in singleplayer? I guess to calculate it, it would be something along the lines of
And also x,y,z are 0,1,2 when in an array?
Code: Select all
self.firstorigin = self getorigin();
wait 1;
self.secondOrigin = self getOrigin();
size = self.firstOrigin[0] - self.secondOrigin[0];
iprintlnBold( size );
Last edited by Opel on June 29th, 2011, 7:54 pm, edited 1 time in total.
Re: Viewpos and mapping
Hmm, i may have a go at recreating that. I guess i would have to use bulletraces and i just can't get my head around on how to use them.
-
- Core Staff
- Posts: 13315
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
Re: Viewpos and mapping
It really isn't hard, It is simply a collection of positions marked with bullettraces and the use of 2D distance.
If I were to recreate the mod, it would be a lot more practical than how I had it.
If I were to recreate the mod, it would be a lot more practical than how I had it.

Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010
-
- CJ G0D!
- Posts: 1575
- Joined: June 3rd, 2009, 9:02 pm
- Location: Cardiff University, UK
Re: Viewpos and mapping
On the subject of bullet traces, how do you return the origin of a bullet trace? Ie. a bullet trade directly down from point A, to point B (point B being the first thing the bullet trace hits), and so it returns the origin of point B?
-
Re: Viewpos and mapping
I believe i've got it. It's not the best way or best coding but it seems to work.
Code: Select all
Â
checks()
{
    self endon( "disconnect" );
   Â
    self.pressed = false;
Â
    for(;;)
    {
        if( self attackButtonPressed())
        {
            self thread checks2();
            self thread trace1();
            self iPrintLn("true");
            self.pressed = true;   Â
        }
        wait 0.05;
    }
    wait 0.05;
}
   Â
Â
Â
checks2()
{
    self endon( "disconnect" );
Â
    for(;;)
    {
        if(self.pressed && self useButtonPressed())
        {
            self thread trace2();
            self iPrintLn("true2");
            self.pressed = false;
        }
        wait 0.05;
    }
    wait 0.05;
}
Â
Â
trace1()
{
    angles = self getPlayerAngles();
    start = ( self getEye() + ( 0, 0, 20 ) );
    end = ( start + vectorscale( anglesToForward( angles ), 4096 ));
Â
    trace = bulletTrace( start, end, false, undefined );
   Â
    self.point = trace["position"];
Â
    self iPrintLn( self.point );
}
Â
trace2()
{
    angles = self getPlayerAngles();
    start = ( self getEye() + ( 0, 0, 20 ) );
    end = ( start + vectorscale( anglesToForward( angles ), 4096 ));
Â
    trace = bulletTrace( start, end, false, undefined );
   Â
    self.point2 = trace["position"];
Â
    self iPrintLn( self.point2 );
Â
    self thread pos();
}
Â
pos()
{
    x = ( self.point[0] - self.point2[0] );
    y = ( self.point[1] - self.point2[1] );
    z = ( self.point[2] - self.point2[2] );
Â
    self iPrintLnBold( "x - " + x );
    self iPrintLnBold( "y - " + y );
    self iPrintLnBold( "z - " + z );
Â
    self iPrintLnBold( "(" + x + " ),(" + y + "),(" + z + ")" );
}
Â
Â
-
- Core Staff
- Posts: 13315
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
Re: Viewpos and mapping
Its not the best code, but if it works, then it works...

Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010
Who is online
Users browsing this forum: No registered users and 2 guests