Dive Board
-
how to get rotatin with a gamepad
how to get rotatin with a gamepad
by jpslara on Apr 27th, 2014 21:28 PM
Hi, some one have get the camera rotation using some control from game-pad adding to head rotation.
I try to get some control to rotate the player, now, when you want to walk in one direction, first you must rotated your actual body in that direction, and then began to walk. I try to use a game-pad control to add some rotation to the rotation get from looking around, but if I add some rotation to the dive script transformation, then I get bad result.
Some one know how to accomplish this.jpslara
Posts: 80
Joined: 27.12.2013
Re: how to get rotatin with a gamepad
by Sephiroth on Apr 28th, 2014 00:24 AM
Are you using the Dive FPS Controller script, and do you want to change the character from strafing to rotating?
Sephiroth
Posts: 45
Joined: 17.03.2014
Re: how to get rotatin with a gamepad
by jpslara on Apr 28th, 2014 09:35 AM
"Sephiroth" wrote:
Are you using the Dive FPS Controller script, and do you want to change the character from strafing to rotating?
Yes, I am using FPS Controller script, and I want to add rotating to character.jpslara
Posts: 80
Joined: 27.12.2013
Re: how to get rotatin with a gamepad
by Sephiroth on Apr 28th, 2014 20:39 PM
It is easy enough to replace strafing with rotation, but if you want to do both it is a bit trickier because of the different gamepads out there.
This will just replace strafing with rotation if you are using the Dive FPS Controller script.
Somewhere around line 123 is :var directionVector = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
change that to :var directionVector = new Vector3(0,0, Input.GetAxis("Vertical"));
and around line 126 change this :if (directionVector != Vector3.zero) {
to this :if (directionVector.y != 0) {
That will remove strafing and so the character can only move forward and backwards.
To make the character rotate add this :if (Input.GetAxis("Horizontal") != 0) {<br /> var rotateVector = new Vector3(Input.GetAxis("Horizontal"), 0, 0);<br /> transform.Rotate(Vector3.up,Time.deltaTime*rotateVector.x*75);<br /> }
before this line (around line 149) :if(jumpcommand==1){
That should do it.Sephiroth
Posts: 45
Joined: 17.03.2014
Re: how to get rotatin with a gamepad
by Sephiroth on Apr 28th, 2014 21:45 PM
oh, forgot to mention on this line
transform.Rotate(Vector3.up,Time.deltaTime*rotateVector.x*75);
you can increase or decrease the number 75 to change the rate of rotation.Sephiroth
Posts: 45
Joined: 17.03.2014
Re: how to get rotatin with a gamepad
by jpslara on Apr 28th, 2014 22:48 PM
"Sephiroth" wrote:
It is easy enough to replace
Thank you, that is cool. I have been you notes very late today, but I hope I can have time next Wednesday and then I can read all code and try to understand it and to implement this. I tell you soon, i hope.jpslara
Posts: 80
Joined: 27.12.2013
Re: how to get rotatin with a gamepad
by jpslara on May 4th, 2014 11:52 AM
Finally, I get rotating after using add_rotation_object from Open dive sensor, and add some angle control to this rotation.
When I solve some issues with map button from gamepad, I will public a new version from angrybots with rotation control from gamepad active.jpslara
Posts: 80
Joined: 27.12.2013
Re: how to get rotatin with a gamepad
by walki77 on Jul 10th, 2014 14:21 PM
Hi thanks for the info exposed. When I make the change gives me error. could put the script fps made for copiarlo.gracias
walki77
Posts: 2
Joined: 10.07.2014
Re: how to get rotatin with a gamepad
by jpslara on Jul 10th, 2014 18:54 PM
"walki77" wrote:
Hi thanks for the info exposed. When I make the change gives me error. could put the script fps made for copiarlo.gracias
Hi, I write this script and put into gameobjet "player" and get rotating with right joystick, but I defined
RHorizontal as 3º axis in Unity input menu. This work well with durovi Dive script
Hola, Escribí este script y se lo añadí al gameobject del jugador, así conseguí rotar con el joystick derecho tras definir en el menú Input de Unity, el tercer eje como "RHorizontal". Esto funciona bien junto con el script de durovis dive.
#pragma strict
private var rotacion : float = 0;
function Update () {
var angulo : Quaternion;
if ( Mathf.Abs(Input.GetAxis("RHorizontal") > 0.5) {
rotacion += 5 * Input.GetAxis("RHorizontal"
rotacion = ((rotacion) % 360);
}
angulo = Quaternion.Euler(0,rotacion,0);
transform.rotation = angulo * transform.rotation;
}jpslara
Posts: 80
Joined: 27.12.2013
RECENT TOPICS
Barrie pest Control
Enhance Your ISC2 CCSP Exam Prep with Dumpsvibe Exam Resources
الاعتماد على تكييف شارب لتبريد مثالي وموثوق
STATISTICS
Total posts: 171536
Total topics: 41569
Total members: 44826
Newest member: Daniel G.
Meet the