Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (TipmyPip, 1 invisible), 18,758 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Script to make models run using alternating keys. #204636
04/30/08 12:13
04/30/08 12:13
Joined: Apr 2008
Posts: 5
I
ItsMe Offline OP
Newbie
ItsMe  Offline OP
Newbie
I

Joined: Apr 2008
Posts: 5
Im trying to script a model running by tapping the left and right keys,
the faster you tap them the faster they run.
The character must simply run in a straight line.

Hopefully this is possible?

If anybody could lend me a land, please post =]



Re: Script to make models run using alternating keys. [Re: ItsMe] #204640
04/30/08 13:21
04/30/08 13:21
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
you'd need to make a function that checks how long it takes to press, release and press a key. I think this will do, but haven't checked it. Use run_speed to move your character.

 Code:
var tap_counter;
var run_speed;

...

while (1) {
  
  if (key_cur || key_cul) {
    tap_counter = 0;
    
    while (key_cur || key_cul) { wait(1); } //wait for the key to be released
    while (!key_cur && !key_cul) { tap_counter += 1 * time_step; wait(1); } //wait for the key to be pressed again, activate counter
    
    run_speed = (key_cur - key_cul) * (1/tap_counter); //calculate direction and multiply by the 'slowness' of pressing key
  }
  
  wait(1);
}


Last edited by Joozey; 04/30/08 13:22.

Click and join the 3dgs irc community!
Room: #3dgs
Re: Script to make models run using alternating keys. [Re: Joozey] #206520
05/14/08 00:27
05/14/08 00:27
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline
Serious User
DLively  Offline
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
Wow, very efficient...


well done. Thanks for sharing this.


Devon.


A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1