KeyPress doubt
Moderator: Moderators
KeyPress doubt
Hello Ville and all ZGE community!
I have a question, since im too noob for ZGE... lol
i made this:
but i don´t know how to use KeyPress to rotate a bit the spacecraft to the left and right (Z?)
can you please help me?
I have a question, since im too noob for ZGE... lol
i made this:
but i don´t know how to use KeyPress to rotate a bit the spacecraft to the left and right (Z?)
can you please help me?
Hi jonaspm,
Attached is a example of the easiest way to do this.
What kind of game are you trying to make?
K
Attached is a example of the easiest way to do this.
What kind of game are you trying to make?
K
- Attachments
-
- Rotate.zgeproj
- (1.14 KiB) Downloaded 441 times
Hi jonaspm,
just a small tip how to achieve more natural behavior. In the example from Kjell change the following expressions in the OnUpdate section of Model:
just a small tip how to achieve more natural behavior. In the example from Kjell change the following expressions in the OnUpdate section of Model:
Code: Select all
CurrentModel.RotationVelocity.Z = 0; ---> CurrentModel.RotationVelocity.Z *= 0.9;
CurrentModel.RotationVelocity.Z += 1; ---> CurrentModel.RotationVelocity.Z = 1;
CurrentModel.RotationVelocity.Z -= 1; ---> CurrentModel.RotationVelocity.Z = -1;
@Rado1
You probably don't want to mix framerate dependent ( *= 0.9 ) and independent ( Velocity ) techniques though. Since I'm using SyncedWithMonitor the deceleration will be slower on monitors with lower refresh-rate / devices with lower performance, while the effective rotation velocity will the constant regardless of framerate.
Also, by changing "-=" and "+=" to "=" the rotation won't stop when you're pressing both left and right at the same time ( which I personally find desirable ).
K
You probably don't want to mix framerate dependent ( *= 0.9 ) and independent ( Velocity ) techniques though. Since I'm using SyncedWithMonitor the deceleration will be slower on monitors with lower refresh-rate / devices with lower performance, while the effective rotation velocity will the constant regardless of framerate.
Also, by changing "-=" and "+=" to "=" the rotation won't stop when you're pressing both left and right at the same time ( which I personally find desirable ).
K
Kjell - yes, you are right. This was just a simplified "didactic" example of how to achieve such an effect easily. In reality, I would use FPS-independent solution, similar to the attached one. (Optionally, I would maybe access rotation directly, not by velocity.)
- Attachments
-
- Rotate.zgeproj
- (1.38 KiB) Downloaded 451 times
Hi jonaspm,
*The windows cursor will only be hidden in a standalone executable, not in the Editor.
K
Depends a little on how you want to handle this ( technically ). A common way is to hide the Windows cursor and show a sprite instead* Attached is a example on how to do this ( albeit a little awkward, the Font component is actually the easiest way to pull this off ).jonaspm wrote:How can i change the cursor icon?
*The windows cursor will only be hidden in a standalone executable, not in the Editor.
K
- Attachments
-
- Cursor.zgeproj
- (2.16 KiB) Downloaded 440 times