I am trying to make an RTS game and i need a way to make walls like this:
Wall building starts at 5:38.
Thank you.
I am trying to make an RTS game and i need a way to make walls like this:
Wall building starts at 5:38.
Thank you.
what you want to do is complicated, so i will expect you to know enough python to understand my code, and fix what needs to be fixed.
you need an object that will control where you place the wall, this will have four properties “x1”, “x2”, “y1” and “y2”.
the properties will record the coordinates of the mouse on the terrain.
the mouse event returns 0 for nothing, 1 for when you start to click, 2 for when you keep clicking, and 3 for when you release the mouse button.
code for an object that will follow the mouse:
sen = cont.sensors[“mouseOver”]
if sen.positive:
obj.worldPosition = sen.hitPosition
code for the controller:
import bge
cont = bge.logic.getCurrentController()
obj = cont.owner
scene = bge.logic.getCurrentScene()
objList = scene.objects
mousepos = objList.get(“mouse”)
left = cont.sensors[“Left”]
mstatus = left.getButtonStatus(bge.events.LEFTMOUSE)if mstatus == 1:
#abs will keep the coordinates in a grid.
obj[“x1”] = abs(mousepos.worldPosition[0])
obj[“y1”] = abs(mousepos.worldPosition[1])
obj[“z1”] = mousepos.worldPosition[2]
elif mstatus == 2:
obj[“x2”] = abs(mousepos.worldPosition[0])
obj[“y2”] = abs(mousepos.worldPosition[1])
obj[“z2”] = abs(mousepos.worldPosition[2])
elif mstatus == 3:
#place the wall
#add the objects
then, you put an object in the first coordinates(“x1”, “y1”) and one in the lasts(“x2”, “y2”), measure the distance beetwen x1 and x2 and y1 and y2 to get how many objects you need, and add using a “for” to fill the space beetwen them. use the third slot in scene.addObject(“”,“”,1) so that the objects are added in the frame and deleted. when you release the mouse button, change that “1” to “0”, and the wall will stay in place.
good luck with your game.
You should be a bit more specific as that is a long video that covers many aspects of gameplay…
Nevertheless, if I understand correctly, you are looking for ploppable assets. For that, I’d start with some tutorials regarding the Mouse Over and Mouse Over Any sensors. I believe this one got me started: https://www.youtube.com/watch?v=5AdQXcFKtuA
You probably also want to look at some tutorials regarding physics to get collisions working as such that the player and/or NPCs can’t walk through the plopped assets. Probably want to look at pathfinding as well, if you’re making an isometric RTS/RPG type game.