Jump to content


Photo

Weapon pick up by holding key


  • Please log in to reply
3 replies to this topic

#1 anerror

anerror

    GMC Member

  • GMC Member
  • 11 posts
  • Version:GM8

Posted 17 March 2012 - 04:59 AM

Hello forum

I am trying to make a top down engine but I want the "E" key to be use different times. I am not sure how to get it to be like most modern FPS games on the PC were you go up to a weapon and hold "E" to switch weapon that was on the ground. right now in the engine I have it so you can switch weapons but the player has them already. please help, with the help right it out in code then tell were I can change code to fit object.
  • 0

#2 Pandaboy

Pandaboy

    GMC Member

  • GMC Member
  • 518 posts

Posted 17 March 2012 - 07:03 AM

make a variable that increases when you hold E. when it reaches a value, pick up the weapon. when released, reset to 0.
  • 0

#3 ramses12

ramses12

    6

  • GMC Member
  • 5769 posts
  • Version:GM8.1

Posted 17 March 2012 - 08:28 AM

Meh it's a complicated situation depending on your current engine. As a starting point, instance_place() is a nice function to know how to deal with.
  • 0

#4 Quazarr

Quazarr

    Neon Ninja

  • GMC Member
  • 183 posts
  • Version:GM:Studio

Posted 19 March 2012 - 02:24 AM

okay so this is what you want to do in the obj_player:
//collision with obj_sword
if keyboard_check_pressed(ord("E")){
instance_change(obj_player_sword,1)//or whatever...
instance_create(obj_player.x+32,obj_player.y+16,obj_sword)
}

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users