right analog stick

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

right analog stick

Postby cullenmac » Tue Sep 15, 2020 3:30 pm

hello is there a way to map my right analog stick to work like a dpad , the new 2k21 has a new shooting method where if you pull the right analog stick exactly straight down with no sway it will automatically score a basket. i didnt know if i could map the down on right dpad to be down on the right analog stick. thank you for your time
is there a way to put this script to my dpad down?

main {
set_val(STICK_1_X,0);
}
User avatar
cullenmac
Sergeant First Class
Sergeant First Class
 
Posts: 18
Joined: Sat Mar 24, 2018 3:41 am

Re: right analog stick

Postby Mad » Tue Sep 15, 2020 8:35 pm

Hi,

Try this:
Code: Select all
main {
    if(is_active(BUTTON_11)) {
        set_val(STICK_1_Y, 100);
    }
}
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord (2K / FPS)
Mad
Major General
Major General
 
Posts: 4532
Joined: Wed May 22, 2019 5:39 am

Re: right analog stick

Postby cullenmac » Tue Sep 15, 2020 10:02 pm

i tried the dpad it didnt work.

main {
set_val(STICK_1_X,-20);
} for anyone who plays 2k21 if you use the shot stick this is perfect but ild like to translate it it to dpad down so i can use the right analog stick to do dribble moves.

i tried the code it was off , is there a way to put this code
to one of my dpads
main {
set_val(STICK_1_X,-20);
} that works with most of my players with a high shot rating and i use this for lower rated shooters
main {
set_val(STICK_1_X,-18);
}
User avatar
cullenmac
Sergeant First Class
Sergeant First Class
 
Posts: 18
Joined: Sat Mar 24, 2018 3:41 am

Re: right analog stick

Postby DontAtMe » Tue Sep 15, 2020 10:12 pm

Right stick to 8-way directional d-pad.
Code: Select all
#pragma METAINFO("steady_aim", 1, 0, "DontAtMe")
fix32 _COS_(fix32 a) { /*^ cos fix */
  a = mod(a + 6.28319, 6.28319);
  if (a < 0.0) a = mod(a += 6.28319, 6.28319);
  if (a > 0.785522 && a < 3.92761) return sin(1.5708 - a);
  return cos(a);
}
fix32 _SIN_(fix32 a) { /*^ sin fix */
  a = mod(a + 6.28319, 6.28319);
  if (a < 0.0) a = mod(a += 6.28319, 6.28319);
  if (a > 0.785522 && a < 3.92761) return cos(1.5708 - a);
  return sin(a);
}
#define sin _SIN_
#define cos _COS_
 
#define STEADY_AIM 45.0
 
main {
  fix32 a = deg2rad(lerp(0.0,360.0,(round(((rad2deg(mod(atan2(get_actual(STICK_1_Y),get_actual(STICK_1_X))+6.28319,6.28319))*(360.0/(fix32)STEADY_AIM))/360.0)))/(360.0/(fix32)STEADY_AIM)))
  fix32 m = sqrt(sq(get_actual(STICK_1_X))+sq(get_actual(STICK_1_Y)));
  set_val(STICK_1_X,clamp(cos(a)*m,-100.0,100.0));
  set_val(STICK_1_Y,clamp(sin(a)*m,-100.0,100.0));
}
 

Change STEADY_AIM value to 90.0 if you would like 4-way directional d-pad.
User avatar
DontAtMe
Captain
Captain
 
Posts: 502
Joined: Tue Oct 02, 2018 4:49 am


Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 86 guests