Just a little help with mouse/ keyboard controllers

(Ah. Don’t know how to delete this post. Gah. Anyways, I got it working! I’ll share the info on the correct post next week maybe.)

( :open_mouth: Oh! I’m so sorry. I posted this in the wrong place. I’ll delete this in a bit if I still don’t get any replies here or where I correctly posted it.)

Hello! New to the whole game making. I’m trying to make a very simple game. You mouse over one of the several blocks, click and drag it, and then drop it. I got this to work with left click. However it would select all the blocks, so I was gonna just try and give each block it’s own keyboard key. (Q,W,E,R… and so on.) However, I can’t get my script to work with keyboard buttons. I downloaded someone’s file, and I learned it worked with both mouse and keyboard buttons. I just need a bit of help here.

My script, which is also from another video I watched:

import bge


cont = bge.logic.getCurrentController()
owner = cont.owner


mouse = cont.sensors["Mouse"]
width = bge.render.getWindowWidth()
width = width/2


pos = mouse.position


posX = width-pos[0]
posX = posX*0.02*-1
owner.localPosition.x = posX


height = bge.render.getWindowHeight()
height = height/2


posZ = height-pos[1]
posZ = posZ*0.02
owner.localPosition.z = posZ

(Here on the top is the downloaded files pic, and the one on the bottom is my own.)



Anyways, I think I just need to tweak the logic nodes or the python. Thanks for any help! :smiley: (So, I know it looks like I just copied and pasted other peoples code. That is pretty much what I did. I’ve done a bunch of messing around with the code and logic, but I still haven’t figured it out yet…)

Attachments