4 registered members (ozgur, Ayumi, VHX, monarch),
1,161
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Problem: Player looking around with mouse
#316243
03/22/10 17:11
03/22/10 17:11
|
Joined: Mar 2010
Posts: 20
KingdaKa
OP
Newbie
|
OP
Newbie
Joined: Mar 2010
Posts: 20
|
Hi everybody.
English:
Iam currently working on my player movement code for my project and i want to code most of it by myself. Its a "Horror-Adventure" in first person view. The player should move and strafe with the arrow keys and look around with the mouse. At the moment, overall its working quite good, but looking around with the mouse isnt working correctly yet. If I move the mouse slowly, everything works fine and smooth. But if I move the mouse fast, the player turns slowly and not smooth. For example: I move the mouse slowy for 1-2 inches, the player turns about 180deg. I move the mouse fast for 3-4 inches, the player turns just about 40deg (Problem with the sampling rate?). Toggle the mouse acceleration on/off in windows, doesnt have effect. In commercial games, everything is working fine for me with this mouse, so this shouldnt be a hardware problem. How can I solve this problem? Is there an alternative for the mouse_force commands? I already tried the mouse_sync command, but it doesnt worked.
My code (cutted):
my.pan -= p_sens * mouse_force.x * time_step; // Mouse movement changing the players pan camera.pan = player.pan; camera.tilt += p_sens * mouse_force.y * time_step; // Mouse movement changing the players tilt if(camera.tilt > 70 ) camera.tilt = 70; if(camera.tilt < -70 ) camera.tilt = -70;
"p_sens" is a variable with pre-defined value 8
I appreciate for any help.
German:
Ich arbeite gerade an der Steuerung für mein Projekt und möchte dabei möglichst vieles selbst schreiben. Es handelt sich um eine "Horror-Adventure" aus der First-Person Sicht. Der Spieler soll mit den Pfeiltasten laufen/strafen können und sich mit der Maus umschauen. Es funktioniert soweit auch ganz gut, nur das Umschauen klappt nicht 100% wie ich mir das wünsche: Wenn ich die Maus langsam bewege, läuft das Umschauen schön flüssig und in guter Geschwindigkeit ab. Bei schnellen Bewegungen geht das Umschauen nur ganz langsam und ruckelig. Bewege ich die Maus langsam um die 2-3cm, dreht der Spieler sich um gute 180°, wenn ich die Bewegung schneller und weiter führe, gerade mal um ca 30° (Problem mit der Abtastrate?). Mausbeschleunigung AN/AUS in Windows macht auch keinen Unterschied. In anderen, kommerziellen Spielen, habe ich damit keine Probleme, es liegt also nicht an meiner Maus selbst. Wie kann man das besser lösen? Gibt es eine Alternative zu den mouse_force Befehlen? Den mouse_sync Befehl habe ich bereits ausprobiert, hat allerdings nichts gebracht.
Meine Variante lautet (Ausschnitt):
my.pan -= p_sens * mouse_force.x * time_step; // Mausbewegung verändert PAN des Players (my) camera.pan = player.pan; camera.tilt += p_sens * mouse_force.y * time_step; // Mausbewegung verändert TILT if(camera.tilt > 70 ) camera.tilt = 70; if(camera.tilt < -70 ) camera.tilt = -70;
"p_sens" habe ich als Variable mit dem Wert 8 festgelegt.
Wäre dankbar für jegliche Hilfe!
Last edited by KingdaKa; 03/22/10 17:14.
|
|
|
Re: Problem: Player looking around with mouse
[Re: KingdaKa]
#316373
03/23/10 16:41
03/23/10 16:41
|
Joined: May 2007
Posts: 2,043 Germany
Lukas
Programmer
|
Programmer
Joined: May 2007
Posts: 2,043
Germany
|
"Mit höherer Maussens, fällt es zwar nicht mehr so auf, ..."
Heißt das, wenn du mit doppelter Mausempfindlichkeit die Maus um die halbe Entfernung verschiebst, funktioniert es? In diesem Fall kann es normalerweise wirklich an der Maus liegen. Aber da du Lasermaus sagst, kann ich mir auch nicht vorstellen, dass die so schlecht verarbeitet wäre. Probier es aber am besten trotzdem mal mit einer anderen Maus aus, oder ob es bei anderen Spielen auch solche Probleme mit der Maus gibt, wenn du die Mausempfindlichkeit niedriger einstellst.
Was auch sein kann, ist dass GS aus irgendeinem Grund bei mouse_force auch bei unterschiedlichen Geschwindigkeiten beim gleichen Weg unterschiedliche Werte zurückliefert. Versuch einfach mal ob es mit mickey besser geht.
|
|
|
Re: Problem: Player looking around with mouse
[Re: KingdaKa]
#316989
03/28/10 13:52
03/28/10 13:52
|
Joined: Mar 2009
Posts: 11 -
tehVolcano
Newbie
|
Newbie
Joined: Mar 2009
Posts: 11
-
|
Das ganze hat ein kleines Problem: mouse_force und mickey sind beide von der Mausbewegunsgeschwindigkeit abhängig. Dass langsame Bewegungen weniger Umdrehung geben, ist also ganz normal. Du kannst aber folgendes versuchen: Ersetze in deinem Code mouse_force.x und mouse_force.y durch variablen, z.b. mousemove_x und mousemove_y. Dann schreibe das hier vor den Rotationscode:
if (mouse_force.x > 0) { mousemove_x = 1;}
if (mouse_force.x < 0) { mousemove_x = -1;}
if (mouse_force.x == 0) { mousemove_x = 0;}
if (mouse_force.y > 0) { mousemove_y = 1;}
if (mouse_force.y < 0) { mousemove_y = -1;}
if (mouse_force.y == 0) { mousemove_y = 0;}
Allerdings wird es schnell auffallen, dass eine konstante Umdrehung nicht besonders gut aussieht. Am besten ist es wirklich, wenn die Umdrehunsgeschwindigkeit von der Mausbewegungsgeschwindigkeit abhängig ist.
Gamestudio A7 Pro
|
|
|
Re: Problem: Player looking around with mouse
[Re: tehVolcano]
#317088
03/29/10 08:48
03/29/10 08:48
|
Joined: May 2006
Posts: 148 Latvia
MTD
Member
|
Member
Joined: May 2006
Posts: 148
Latvia
|
You could use mickey.x in mouse_force.x Have tried to change players pan with mickey.x and it worked my.pan -= p_sens * mickey.x * time_step;
|
|
|
|