Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: Control actor with keyboard  (Read 3980 times)

0 Members and 1 Guest are viewing this topic.

masterj

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 12
    • View Profile
Control actor with keyboard
« on: April 03, 2009, 11:45:43 AM »

Hey everyone :) Newbie in da house  O0

Could someone please help me with the script code to control my actor walk with keyboard (up, down, left, righ,up+left,up+right,down+left,down+right)?

Thanks in advance
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Control actor with keyboard
« Reply #1 on: April 03, 2009, 12:00:49 PM »

2D actor? 3D actor?
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

masterj

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 12
    • View Profile
Re: Control actor with keyboard
« Reply #2 on: April 03, 2009, 01:14:42 PM »

2D

At the moment i'm using:
   if (Keyboard.KeyCode == VK_UP) {
      actor.GoTo(actor.X, actor.Y-50);
   } else if (Keyboard.KeyCode == VK_DOWN) {
      actor.GoTo(actor.X, actor.Y+50);
   } else if (Keyboard.KeyCode == VK_LEFT) {
      actor.GoTo(actor.X-50, actor.Y);
   } else if (Keyboard.KeyCode == VK_RIGHT) {
      actor.GoTo(actor.X+50, actor.Y);
   }

But actor goes really strange sometimes it looks like he is trying to step first step again ant again instead of just going
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Control actor with keyboard
« Reply #3 on: April 03, 2009, 01:17:34 PM »

I recommend getting Igorrr's 'Spank the hero' demo: http://www.igorrr.com/files/SpankTheHero_v0.30.zip
It's pretty old now, but still very useful.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

masterj

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 12
    • View Profile
Re: Control actor with keyboard
« Reply #4 on: April 03, 2009, 01:40:08 PM »

OK, So i've put direct_control.script to scripts folder. Now how do I include it to run everytime I load game? I've tried #include in game.script, but log showed me many errors about variables being already declared and script just stops
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Control actor with keyboard
« Reply #5 on: April 03, 2009, 01:55:33 PM »

Just like Spank The Hero does: in ProjectMan, in the left properties pane add the script in the "Scripts" field.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

masterj

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 12
    • View Profile
Re: Control actor with keyboard
« Reply #6 on: April 03, 2009, 09:59:48 PM »

thank you :) finnaly i'm able to control my actor trough keyboard :)
Logged
 

Page created in 0.038 seconds with 20 queries.