left analoge

GPC2 script programming for Titan Two. Code examples, questions, requests.

left analoge

Postby peter373635 » Fri May 21, 2021 12:20 pm

hi, im looking for a little script for titan two that the anologue stick will only move at 1 speed no matter how fast or slow i move it. i need to be able to mess around with the variable so i can determine the speed i need. also if poss the anologe stick to move as soon as i touch it(if thats possible at all) many thanks
User avatar
peter373635
Sergeant
Sergeant
 
Posts: 7
Joined: Mon Nov 23, 2020 9:18 am

Re: left analoge

Postby EternalDahaka » Fri May 21, 2021 10:32 pm

Code: Select all
//CHANGE THESE VALUES
fix32 deadzoneL     =   0.00;
fix32 sensitivityL  = 100.00;
 
main {
 
    applySticks(deadzoneL, sensitivityL);
 
}
 
void applySticks(fix32 dead, fix32 sens){
 
    fix32 x, y;
    x = get_val(STICK_2_X);
    y = get_val(STICK_2_Y);
 
    fix32 magnitude = sqrt(x*x + y*y);
    fix32 outX = x/magnitude;
    fix32 outY = y/magnitude;
 
    if(magnitude > dead){
 
        outX = clamp(outX*sens, -100.00, 100.0);
        outY = clamp(outY*sens, -100.00, 100.00);
 
        set_val(STICK_2_X, outX);
        set_val(STICK_2_Y, outY);
 
    }
    else{
        set_val(STICK_2_X, 0.0);
        set_val(STICK_2_Y, 0.0);
    }
}


Keeps distance at whatever the sensitivity is set to regardless of angle. Use 0.00 to 100.00 values to customize either value.
100.0 sensitivity is "max" sensitivity, 0.00 is no movement.

This triggers with any movement, but I'd recommend setting a modest deadzone because small movements can output dramatic angle differences.
User avatar
EternalDahaka
Staff Sergeant
Staff Sergeant
 
Posts: 15
Joined: Tue Feb 23, 2016 7:12 am

Re: left analoge

Postby peter373635 » Sat May 22, 2021 12:16 pm

superb,thanks..will try it in a bit
User avatar
peter373635
Sergeant
Sergeant
 
Posts: 7
Joined: Mon Nov 23, 2020 9:18 am

Re: left analoge

Postby peter373635 » Tue May 25, 2021 9:27 am

hi, i tried it but controller not working like a normal controller with this code. not sure why but thanks for trying anyway,not sure why because even with inputs at 100% its acting weird. thanks for trying tho
User avatar
peter373635
Sergeant
Sergeant
 
Posts: 7
Joined: Mon Nov 23, 2020 9:18 am


Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 97 guests