Movement Help

Okay I’ve got all the characters and landscape and animation ready. Now all I need is to implement them in a game. Since there are a lot of RPG and FPS around I decided to do a turn-based strategy game like Disgae and Final Fantasy Tactics Advance. But the problem is I can’t write a proper script for the movement. Here’s a couple of pictures on the type of movement I want. The landscape has to be divided into squares and characters can only move onto one of these square each turn. They can then attack other characters. Please help!!

Attachments




you are in blender right? and you want movment like an rpg? ok start by adding a property to count movement. name it say “move” now you will have to right 4 scripts (one for each dirrection) and they should go something like this.

 
 
 
#move x 1
# get controller
controller = GameLogic.getCurrentController()
# get the object this script is attached to
player = controller.getOwner()
#get players x position
p1x = player.getPosition()[0]
p1y = player.getPosition()[1]
p1z = player.getPosition()[2]
p1newpos = [(p1x + 1), p1y, p1z]
player.setPosition(p1newpos)


 
#move x -1
# get controller
controller = GameLogic.getCurrentController()
# get the object this script is attached to
player = controller.getOwner()
#get players x position
p1x = player.getPosition()[0]
p1y = player.getPosition()[1]
p1z = player.getPosition()[2]
p1newpos = [(p1x - 1), p1y, p1z]
player.setPosition(p1newpos)


 
#move y 1
# get controller
controller = GameLogic.getCurrentController()
# get the object this script is attached to
player = controller.getOwner()
#get players x position
p1x = player.getPosition()[0]
p1y = player.getPosition()[1]
p1z = player.getPosition()[2]
p1newpos = [p1x, (p1y + 1), p1z]
player.setPosition(p1newpos)

  
#move y -1
# get controller
controller = GameLogic.getCurrentController()
# get the object this script is attached to
player = controller.getOwner()
#get players position
p1x = player.getPosition()[0]
p1y = player.getPosition()[1]
p1z = player.getPosition()[2]
p1newpos = [p1x, (p1y - 1), p1z]
player.setPosition(p1newpos)

copy all those codes into diferent texts and neme them the first thing on them. exmp:
it says

move x 1

name it “move x 1”

now follow this picture to set up the logic bricks


dont forget the property

basicly to change the amout of times it can move change the # on the property and make sure the max # on the property sensor is higher than it. (it dosent have to be the same just higher than it)

send me a private message if you have any questions

one issue with this is this script does not allow for colision it willset it to that location no mater what and if it hits something it may go flying into the air (assuming its dynamic) also it does not move on the z axes so stairs and or ramps could be a problom. I could create other scripts for you that would set the hight to a specific hight when it colides with a spicific hight peice of land scape so it will be on top of it. but if your landscape is flat this wont be nesisary.

@Kylona - That code is for 2.49, which won’t work in 2.5 (if that is what Asif is using).

@Asif - If you’re trying to make a game like that, let me tell you now that you should learn Python, because it’s quite a complex game. Almost every part of it will require math (how many spaces each character can move, how far each character can attack, how much damage each character gives, how many people are on each team, etc), so you should definitely use Python. If you don’t know Python, it’s not that hard - just start picking some up. If you do know Python, that’s great. From there, we can help you out more-so.

@SolarLune ya thats true mebey i should learn 2.5. Ive been use 2.49 because i like the layout alittle beter. Ill work on it

Kylona’s script will work if i add these in the first few lines,right?
import logic from bge
controller = logic.getCurrentController()

2.5 code


from bge import logic as gl
#move x 1
# get controller
controller = gl.getCurrentController()
# get the object this script is attached to
player = controller.owner
#get players x position
p1x = player.position[0]
p1y = player.position[1]
p1z = player.position[2]
p1newpos = [(p1x + 1), p1y, p1z]
player.position=p1newpos