2D platform game Help !!

Hi iam making a 2D platform game (from side view ) wanted to know how to do these things :
1-The player looks at the left when i press (w) and mirrors(looks the ther side when i press (A).
2- simple mouse look to target a weapon ( I mean mouse look for only up and down ).

Hope someone help. :frowning:

  1. Several Options. For Example, you can use two different Vectors and use alignAxisToVect so the Character turns towards the Direction he moves towards.
  2. Have an Object on Screen that always clings to the WorldPosition the Mouse points to on Screen, and then have whatever Part of the Character shall align (Upper Body Bone? Aiming Crosshair?).

You will need Python or this will be a Pain. :wink:

will you excatly give the script for both because i dont understand python.
And icouldnt understand what do you neab in number 2.

This seems quite useless to me, but I give you a shortened Version of a Player Script I once wrote, but you will have to check the Console because I assure you that there will be one or another Thing not working properly – it’s just not to be expected from a foreign Script.
You better search the Resources Forum for Movement Scripts, they are more likely to be »Templates«.


from bge import logic as g
from bge import events as e

cnt=g.getCurrentController()
own=cnt.owner

pldir=own.children["pl_dir"]
grounded=cnt.sensors["jump"] #a Ray Sensor called "jump", pointing downwards
collisio=cnt.sensors["Collision"] #Surprise, a Collision Sensor
speed = 11
jumpheight = 14

#######
#MOVIN'
keyboard = g.keyboard.events
if grounded.positive:
 if keyboard[e.WKEY] or keyboard[e.UPARROWKEY]:
  own.localLinearVelocity[2]=jumpheight
 if keyboard[e.AKEY] or keyboard[e.LEFTARROWKEY] or keyboard[e.DKEY] or keyboard[e.RIGHTARROWKEY]:
  if keyboard[e.AKEY] or keyboard[e.LEFTARROWKEY]:
   own.alignAxisToVect((-1,0,0),0,1.0)
   own.localLinearVelocity[0]=-speed
  if keyboard[e.DKEY] or keyboard[e.RIGHTARROWKEY]:
   own.alignAxisToVect((1,0,0),0,1.0)
   own.localLinearVelocity[0]=speed
 else:
  own.localLinearVelocity[0]=0
else:
 #own.localLinearVelocity[0]=speed*0.25
 #allow Player to drift horizontally while in Air
 if own.localLinearVelocity[2]>-11:
  own.localLinearVelocity[2]-=0.3

About 2)
Give an Object [Mouse Over Any > Python Script]



from bge import logic as g
cnt=g.getCurrentController()
mr=cnt.sensors["Mouse"]
cnt.owner.worldPosition=(mr.hitPosition[0],0,mr.hitPosition[2])

And then have the Weapon target the Object via [Edit Object > TrackTo]

:S :S :? this is soooo hard I have never used python so please tell me what actuators shouldi use and what sensors and please make an easier script

An easier Script? It already is very, very simple, it just seems so cofusing as you don’t understand it, that is very usual.

Both Scripts must be existent by using the Text Window, clicking the [+]-Button, thus creating a new Script, pasting the Script in there, and giving the Script a proper Name, rather than just »Text«.
Then:
One Always Actuator (first […]-Button activated) connected to a Python Controller for the first Script (pretty much the Default Method, I would say).
One Mouse Actuator […] set to »Mouse Over Any« connected to a Python Controller with the second Script.