I have attached a copy of my game i made from the war battle tutorial, I need some help with the programming. what i need help with is running the title screen(being able to click play and the game starts), next I am having trouble with factories and spawning my units, after they are spawned i don’t really know how to program AI, next i have medics that heal but i need to work on the UI health bar for the player i have an idea of what i want to do just the 5 bars and each time player is hit it’s alpha goes to 0 showing the next bar and if he walks into a medic then it will heal and go back to the previous health bar. another mechanic in my game i’m not sure how to add would be power-ups making the guy shoot multiple missiles again i need help with spawning the item and finally i want to make waves of enemies that come in and the game to tell you your score at the end then you can click play again. I have already set up everything, like the factories and grouped and masked everything all i’m really lacking is the hard programming. if anybody can help it would be cool i looked on the boards and the topic about spawning tanks was set up different then mine so it didn’t really work when i tried it in my project so i came to a wall. I’ll probably look at the documentation of coding if i can’t find any help but this is a cool community and i really want to see my baby come to life… well the tutorial i followed and then asked people for help to complete baby but my baby none the less that taught me well and will lead to new babies!
Maybe someone will pick up your code and implement the things you are asking for, but my recommendation is that you try and learn these things yourself. How else are you going to create your next game? Break this post down into multiple questions. I’ll provide some help for #1, the title screen.
How to create multiple screens and navigate between them?
You have multiple options. One would be to use an extension, for instance Monarch. Check our asset portal. It allows you to set up multiple screens and navigate between them. If you want to do it yourself I recommend this example: https://github.com/britzl/publicexamples/tree/master/examples/menu_and_game
i’ve been looking at what to do for the ai i made collision spheres and the have a message_id for trigger response but im stuck on how to make the tanks move towards my player game object. and then i added a button input for the title screen but i don’t know what command runs the actual level. also when i try to pass the score to an endscore node in my gui it throws up an error code
There is also the Color Slide tutorial which for some reason isn’t among our Tutorials (ping @sicher). It goes into the details of how to add navigation to a game.
thanks a lot man. i was looking at your example and incorporating it into my project that makes sense when you explain it, thanks a lot. starting to make a lot of sense now
I will check that out, so i got my tanks wandering around the map i can shoot them and it scores. my title screen is set up but how do i get that to play first? after that i think i just need some random spawing from my factories and then i’ll be getting close to an actual game!
@sicher, @britzl alright so i have created proxy groups and implemented the code and my title screen loads then when i click the button i get an error saying the message can’t post to the controller script “show_game”, the next thing i need help with is my tanks spawning i think the problem lies within the vector3 part im not sure it says something about nil and can not spawn tank. i put music in it too but the music doesn’t play im sure that is simple but i don’t know what passes a message to the music script to play sound that it is scripted to play or like what activates it i have the script and the sound object linked to a wav file. and while im making a laundry list of questions IM SORRY but is there any examples that go over raycasting?
local function random_position()
return vmath.vector3(math.random(40, 996), math.random(40, 996), 0)
end
local function spawn_enemy()
return factory.create("#enemy_factory", random_position())
end
local function spawn_medic(position)
return factory.create("#medic_factory", random_position())
end
local function spawn_helicopter()
return factory.create("#helicopter_factory", random_position())
end
local function spawn_tank(position)
return factory.create("#tank_factory", random_position())
end
local function spawn_powerup(position)
return factory.create("#powerup_factory", random_position())
end
function init(self)
msg.post(".", "acquire_input_focus")
math.randomseed(os.time())
self.tank = {}
self.powerup = {}
self.medic={}
self.helicopter={}
self.enemy={}
for i = 1, 10 do
table.insert(self.tank, spawn_tank())
end
end
function final(self)
msg.post(".", "release_input_focus")
end
function update(self, dt)
if messag_id==("collision_response") then
table.insert(self.tank, spawn_tank(vmath.vector3(random_position(40,996),random_position(40,996),0)))
if #self.tank==0 then
msg.post("controller:/controller","show_menu")
end
end
this is the game script that doesn’t spawn
function on_input(self, action_id, action)
ERROR:SCRIPT: /main/scripts/title.gui_script:12: Could not send message ‘show_game’ from ‘main:/title/title#title-screen’ to ‘controller:/controller’.
stack traceback:
[C]: in function ‘post’
/main/
and yes i did look at the documentation that’s how i fixed most of the code, this was the other error i got but i fixed it kind of the guy dies now if a tank runs into him as well
ERROR:SCRIPT: /main/scripts/game.script:34: attempt to get length of global ‘tank’ (a nil value)
stack traceback:
/main/scripts/game.script:34: in function </main/scripts/game.script:22>
DEBUG:SCRIPT
I don’t understand. Your code spawns tanks in the init() function of “game controller” and you say they move around so clearly they have spawned. There is no other code that spawns tanks anywhere in that gist.