HTML5 Game (Canvas) UI Techniques? I'm in the process of building a JavaScript HTML5 game (using Canvas) for mobile (Android iPhone WebOS) with PhoneGap. I'm currently trying to design out how the UI and playing board should be built and how they should interact but I'm not sure what the best solution is. Here's what I can think of Build the UI right into the canvas using things like drawImage and fillText Build parts of the UI outside of the canvas using regular DOM objects and then float a div over the canvas when UI elements need to overlap the playing board canvas. Are there any other possible techniques I can use for building the game UI that I haven't thought of? Also, which of these would be considered the "standard" way (I know HTML5 games are not very popular so there probably isn't a "standard" way yet)? And finally, which way would YOU recommend use? Many thanks in advance!


Logic only GUI library I'm not sure whether this place is the correct for asking this. If it's the wrong place I'm sorry, please tell me if so! I'm making a small game for fun which would uses an own engine with OpenGL and Vulkan as underlying renderer implementation. The engine itself is targeted for Mono .Net. Currently I'm not yet there but I'll come to the point where I'm pushed to implement some kind of GUI (I'm thinking ahead because of good design). I already searched the Internet for render independent GUI systems but I wasn't lucky yet. As result I thought about how I could implement the GUI on my own and came to the conclusion a independent implementation is needed which takes care only for layout, positioning of GUI objects with responding to inputs. another implementation is needed which only takes the results of calculations for rendering (the renderer) Before I start inventing the whole wheel new I simply want to know Is it a correct approach to doing it this way? Is there a different common approach doing what I described?


AntTweakBar doesn't register SFML mouse events I'm trying to add GUI for easier level editing in our game engine. We're using SFML for all the basic stuff (window management, input events etc). I've chosen AntTweakBar because it is a well known library with a few examples around. I was following the tutorial at AntTweakBar's website I was able to draw a simple bar with those example codes. However, mouse events received by SFML are not registered by AntTweakBar's TwEventSDL() function. Here is an example code for Input sf Event event while ( pWindow gt pollEvent(event)) Check if the event should be handled by AntTweakBar int handled TwEventSFML( amp event, 2, 3) for SFML version 2.3 if (!handled) switch (event.type) case sf Event MouseButtonPressed To check whether SFML received mouse button events properly if (event.mouseButton.button sf Mouse Button Left) std cout lt lt "Left button pressed" lt lt std endl std cout lt lt "x " lt lt event.mouseButton.x lt lt std endl std cout lt lt "y " lt lt event.mouseButton.y lt lt std endl else To check whether TwEventSFML received events std cout lt lt "FINALLY!" lt lt std endl When I press buttons, I can see "FINALLY!" showing up. I can also see that my mouse clicks are received by SFML. However, when I click on an AntTweakBar element (be it a button or help section) it doesn't register it. (Also, I can't see "FINALLY!" when I use the mouse). Any help or ideas will be appreciated.


How to make a scrollbar? I am making my own UI for my game, no libraries used, basic UI with simple controls and I am almost done. Now, let's say I need to display lots of information, controls or items which obviously won't fit in the screen space. I must use a scroll bar to achieve this task. But how does one make a scroll bar? I just don't understand how to do it. The concept for vertical and horizontal scrollbars is the same. Virtually there is a huge plain with data, but we can only display cut of it all in a such by such screen space. We use scrollbars to move that viewable rectangle across our giant plain. The scrollbar itself is a displayed line texture sprite on the side of the screen which has a button inside that we can interact with by moving it across the scrollbar. The button is dynamic, its size is relative to total item count and possible item count that can be shown in given space. Our button shrinks when there are more items added, expands when items are getting removed and the whole scrollbar disappears when all the items can be successfully displayed at once. I can't seem to find online tutorials on this matter. Perhaps it's so basic for everyone except me? Still can't wrap my head around it...


Tech Tree layouts for games? I'm trying to do a tech tree GUI for my game, but i have limited width and the tree has alot of branches, the problem is if I make them small to fit the width, the tech tree is too small to read. For example the AOE one is very large (in width) I could allow scroll bar but as its web based, scrolls are quite ugly. So i was wondering how to deal with branches which slowly cause the tech tree to get wider as you go down the tech tree and how you would fit such a design in a limited space. Are there different known designs for tech trees that any one knows of so i can look at their types. I don't know the names given to the types of tech tree layouts. But am hoping to find one that is not overly complex for the user aswell.


What is the best way to make a main menu system? I know that's it's easy to make buttons that highlight when you move your mouse over them, but when it comes to sub menus I'm kinda stuck. Anyone got some tips on the best way to have a main menu with sub menus? (like Singleplayer Load Save Save 1 5? Start game etc.)


What is the specific name of this UI component? Is there a specific name for this kind of ui component? Sometimes it only renders a symbol (without text) so using name like TextComponent is imo not very fitting.


How to create guides to off screen objects? I've played Metroid Blast on Wii U, and would like to build one of its features in a three.js game. The feature is if an opponent is out of view, a guide is displayed showing the direction of the opponent. An example of it is here (Image source) Notice the small circles with arrows in the left side. How could I have a similar feature in my game?


How to create game database editor interface like Age of Empires' AGE Age of Empires had this powerful AGE (Advanced Genie Editor) tool to let players mod the game data with ease. You could see all the game's databases through this tool and play with them to make your own mods in a pretty straightforward way, which I suppose was also used by the devs themselves to author their data. I was wondering how can I implement a similar editing interface for my game database? Are there tricks like this that Godot, Unity and Unreal users use to author their data? I feel like I missed something because no popular engine seem to support what I'm looking for out of the box. If I can't do it in engine, how should I go to make such a tool myself?


How do I attach UI data to logic data? I'm attempting to write an inventory system(C , doesn't need to be huge), that later on should be able to be drawn in a GUI. In the file structure, I think it would be best to put both information about the item itself and references to graphics, etc. in one file. But how does that translate into code? How should I tell the renderer, for example which sprite to draw for which item and where to do that. Should I only have the CInventory and the CItem class, containing both logic and sprite information, or should I create separate logic and GUI inventory(in this case meaning both CInventory and CItem) classes which are then linked by a common item id for example? Answers are always appreciated )


Immediate GUI yae or nay? I've been working on application development with a lot of "retained" GUI systems (below more about what I mean by that) like MFC, QT, Forms, SWING and several web GUI frameworks some years ago. I always found the concepts of most GUI systems overly complicated and clumsy. The amount of callback events, listeners, data copies, something to string to something conversions (and so on) were always a source of mistakes and headaches compared to other parts in the application. (Even with "proper" use of Data Bindings Models). Now I am writing computer games ). I worked with one GUI so far Miyagi (not well known, but basically the same Idea as all the other systems.) It was horrible. For real time rendering environments like Games, I get the feeling that "retained" GUI systems are even more obsolete. User interfaces usually don't need to be auto layouted or have resizable windows on the fly. Instead, they need to interact very efficiently with always changing data (like 3d positions of models in the world) A couple of years ago, I stumbled upon "IMGUI" which is basically like an Immediate Graphics mode, but for user interfaces. I didn't give too much attention, since I was still in application development and the IMGUI scene itself seemed to be not really broad nor successfull. Still the approach they take seem to be so utterly sexy and elegant, that it made me want to write something for the next project using this way of UI (I failed to convince anyone at work (...) let me summarize what I mean by "retained" and "immediate" Retained GUI In a separate initialization phase, you create "GUI controls" like Labels, Buttons, TextBoxes etc. and use some descriptive (or programmatical) way of placing them on screen all before anything is rendered. Controls hold most of their own state in memory like X,Y location, size, borders, child controls, label text, images and so on. You can add callbacks and listeners to get informed of events and to update data in the GUI control. Immediate GUI The GUI library consists of one shot "RenderButton", "RenderLabel", "RenderTextBox"... functions (edit don't get confused by the Render prefix. These functions also do the logic behind the controls like polling user input, inserting characters, handle character repeat speed when user holds down a key and so on...) that you can call to "immediately" render a control (doesn't have to be immediately written to the GPU. Usually its remembered for the current frame and sorted into appropiate batches later). The library does not hold any "state" for these. If you want to hide a button... just don't call the RenderButton function. All RenderXXX functions that have user interaction like a buttons or checkbox have return values that indicate whether e.g. the user clicked into the button. So your "RenderGUI" function looks like a big if else function where you call or not call your RenderXXX functions depending on your game state and all the data update logic (when a button is pressed) is intermangled into the flow. All data storage is "outside" the gui and passed on demand to the Render functions. (Of course, you would split up the big functions into several ones or use some class abstractions for grouping parts of the gui. We don't write code like in 1980 anymore, do we? )) Now I found that Unity3D actually uses the very same basic approach to their built in GUI systems. There are probably a couple of GUI's with this approach out there as well? Still.. when looking around, there seem to be a strong bias towards retained GUI systems? At least I haven't found this approach except in Unity3D and the original IMGUI community seems to be rather .... .. quiet. So anyone worked with both ideas and have some strong opinion? Edit I am most interested in opinions that stem from real world experience. I think there is a lot of heated discussions in the IMGUI forum about any "theoretical weakness" of the immediate GUI approach, but I always find it more enlightening to know about real world weaknesses.


Error in DRAW GUI event on android. (GameMaker) Image of the game on a mobile phone As you can see the maze (draw event) has been resized correctly. But the yellow post it (draw GUI event) has not been scaled or displayed in the correct location (center of the screen). Same thing with GUI layout (draw GUI event). Because this is a small stage room (size) I do not use the artifice of views, I thought that could be because of that the problem, but I enabled the views and did not get any different result. Picture of the game on a computer (like it should be on the phone) OBS One information that can help you to help me solve the problem, is that to draw the post it I use the following code draw GUI event draw sprite(spr Post,0,640,360) . 640 is the half screen width of the game and also the room, 360 is half the height of the game screen and also the room. It seems that somehow the room on the cell phone is different size than 1280x720. I do not put the following code draw GUI event draw sprite(spr Post,0,room width 2,room height 2), because there are much larger phases that need views, so the post it needs to be in the center of the screen of the player, and with this code it ends up being in the center of the phase. I tested the game on Bluestacks and it did not happen the same as on the phone.


Unity 5 Dynamic Button Creation with Event Parameters According to the documentation, you cannot instantiate buttons except via prefab instantiate. http docs.unity3d.com Manual HOWTO UICreateFromScripting.html You might wonder why we don t have a API methods to create the various types of controls, including visuals and everything. The reason is that there are an infinite number of way e.g. a button could be setup. Does it use an image, text, or both? Maybe even multiple images? What is the text font, color, font size, and alignment? What sprite or sprites should the image use? By letting you make a prefab and instantiate that, you can set it up exactly the way you want. And if you later want to change the look and feel of your UI you can just change the prefab and then it will be reflected in your UI, including the dynamically created UI. What I'm trying to do is dynamically create a table of buttons, each one going to a level in my game. The amount of button depends on how many levels the user has unlocked. I can create a prefab for a button, that's fine, but how do I go about assigning an OnClick event to each of these buttons with an appropriate 'levelIndex' parameter? I can not find any scripting method to do this, and I'd like to avoid hacky solutions like creating 50 buttons and only showing the first N children.


Why isnt setting the global position working? Previously my items were relative to the player by node hierarchy. But for items like bombs this is not ideal so i tried to add the items to the world scene, but when i try to adjust the position of the item to the players position it doesnt work and i see the sword in the top left corner of the screen the worlds origin. Entity Script func use item(item) var newitem item.instance() newitem.own self newitem.global position global position not setting the position of the item correctly newitem.add to group(str(newitem.get name(), self)) get node( quot .. quot ).add child(newitem) if get tree().get nodes in group(str(newitem.get name(),self)).size() gt newitem.maxamount newitem.queue free() Sword Script func ready() type own.type anim.connect( quot animation finished quot ,self, quot destroy quot ) anim.play(str( quot swing quot ,own.spritedir)) if own.has method( quot state swing quot ) own.state quot swing quot func destroy(animation) if own.has method( quot state swing quot ) own.state quot default quot queue free() It seems like it should work but with an engine like godot there could be several reasons why a certain thing is not working. https github.com MonkeyToiletLadder wendingo could it be that in my animation player i set the sword positions as key frames and thats why its not working?


Godot Get button node in click event not working How we can get the button reference on the event function that is connected? My connect signals never works extends PanelContainer onready var hbox container ScrollContainer HBoxContainer var btn func ready() createbutton() func createbutton() btn Button.new() btn.set name("button 1") btn.text "button 1" hbox container.add child(btn) btn.connect("toggled", self, "button toggled", btn ) func button toggled(toggled, target) print("which button ", target.get name()) if toggled true print("Button ist pressed") else print("Button is released")


Add a sound to all the buttons in a project Is there an option on the texture button or something like that where you can specify a sound to be played on button press. I have created a global sound manager but for the button presses, I have to manually code it everywhere the script has a button pressed signal. Or some kind of logic that when a button is pressed anywhere in the project, sound manager plays a particular sound.


How can I remove Godot's splash screen? I started using Godot lately (mostly because the editor supports Linux). There is one thing that bothers me the Godot splash screen. I know that I can (somehow) remove it and I saw something about C but I'm not sure. Is there any way to remove it? Or maybe it is only in the editor and once you export the game it'll disappear?


Lagging problem with chunk creation in Godot We are developing a 2D game in Godot and we are stuck while trying to divide the map in chunks. Namely, the scene is a forest, where trees spawn positions were generated by noise since the trees are too many to be loaded altogether, we created a Chunk node, which only instances trees contained in it, and gets instanced and deinstanced according to player's position. Though, this does not seem to be enough each time a new chunk is to be instanced, we get a lag spike. How can we improve this? This is the script attached to Chunk extends Node2D var noise func ready() randomize() self.name str(global position) noise get node(" root global").noise LoadTrees() func LoadTrees() var x 38 while x lt 39 var y 14 while y lt 15 if noise.get noise 2d(global position.x float(10 x),global position.y float(12 y)) gt 0.07 InstanceTree(Vector2(10 x rng.randi range( 3,3),12 y rng.randi range( 3,3)),self) y 1 x 1 func on Exit body exited(body) if body.name "Player" call deferred("free") func on AreaLeft body entered(body) if body.name "Player" var NewChunkPos global position 2 Vector2(380,0) get parent().InstanceChunk(NewChunkPos) func on AreaRight body entered(body) if body.name "Player" var NewChunkPos global position 2 Vector2(380,0) get parent().InstanceChunk(NewChunkPos) func on AreaDown body entered(body) if body.name "Player" var NewChunkPos global position 2 Vector2(0,170) get parent().InstanceChunk(NewChunkPos) func on AreaUp body entered(body) if body.name "Player" var NewChunkPos global position 2 Vector2(0,170) get parent().InstanceChunk(NewChunkPos) The functions the script calls from its parent's script go as follows func InstanceTree(pos,Parent) var tree Tree.instance() tree.position pos tree.name str(global position) " tree " str(pos) Parent.call deferred("add child",tree) func InstanceChunk(NewChunkPos) if not self.has node(str(NewChunkPos)) var NewChunk Chunk.instance() NewChunk.global position NewChunkPos NewChunk.name str(NewChunkPos) call deferred("add child",NewChunk)


Godot How does the VisibilityEnabler work? Visibility Enabler I'm confused about the use of the Visibility enabler node in godot. I've read the documentation and tried it out both stand alone and as a child without success. I set the parent to print a String during its process function. Despite adding the enabler it continued to print despite being off screen. How do I set it up so that It actually disables anything?


How do I get the GUI to draw above the kinematic bodies when their z index is changed? Currently the Labels in the GUI are below the player and other objects, so the player appears above them. How can this be fixed? extends Node var load 1 true onready var level preload("res scenes levels Level.tscn") var Level null func ready() Level level.instance() add child(Level) move child(Level, 0) VisualServer.canvas item set z index( GUI Label3, 4000) print("I'm here") func process(delta) getallnodes(self) pass func set z index(node) for N in node.get children() if N.get class() "KinematicBody2D" N.z index N.position.y func getallnodes(node) for N in node.get children() if N.get child count() gt 0 and N.get class() ! "RigidBody2D" and N.get class() ! "KinematicBody2D" and N.get class() ! "StaticBody2D" getallnodes(N) else if N.get class() "KinematicBody2D" or N.get class() "RigidBody2D" setZOrder kine(N) print(" " N.get name()) if N.get class() "StaticBody2D" setZOrder kine(N) print(" " N.get name()) elif N.get class() "Sprite" setZOrder(N) print(" " N.get name()) func setZOrder kine(node) for N in node.get children() if N.get class() "Sprite" var myPos N.get global transform().get origin() var mySize N.get texture().get height() var bottomOfSprite (mySize N.get scale().y N.get parent().get scale().y) (2 N.vframes) N.get parent().z index (myPos.y bottomOfSprite) func setZOrder(N) var myPos N.get global transform().get origin() var mySize N.get texture().get height() var bottomOfSprite (mySize N.get scale().y) (2 N.vframes) N.z index (myPos.y bottomOfSprite) func physics process(delta) if(Level.get node("Player")) GUI Label.text "Velocity " str(Level.get node("Player").velocity.length()) ", " str(Level.get node("Player").velocity.x) ", " str( Level.get node("Player").velocity.y) GUI Label2.text "Position " str(Level.get node("Player").position.x) ", " str(Level.get node("Player").position.y) ", " str(Level.get node("Player").z index) GUI Label3.text "Sword " "rotation " str(Level.get node("Player").rotation) GUI Label4.text "stamina" str(Level.get node("Player").stam.current) "attack charge " str(Level.get node("Player").stab.charge.current) "countdown " str(Level.get node("Player").stab countdown 0 ) "cooldown " str(Level.get node("Player").stab cooldown 0 )


Godot on Area2D area entered not detecting In my Scene I have a Node2D. I then Instanced the Player and Area2D nodes. The Area2D has a signal pointing to itself that prints test when run. Here is the Code For the Area2D. Nothing happens when an object enters the Area2D. extends Area2D Declare member variables here. Examples var a 2 var b "text" Called when the node enters the scene tree for the first time. func ready() pass Replace with function body. Called every frame. 'delta' is the elapsed time since the previous frame. func process(delta) pass func on Area2D area entered(area) print('test') Level Scene Player Area 2D Google Drive Link to Project https drive.google.com drive folders 1OG3BBqKJzC3Je r5eQdqiFUp7PzzBmt1?usp sharing


How do I decrease the scale of an instanced node or scene? I'm trying to decrease size of instanced RigidBody2D scene, through code. With scale(), I'm trying to decrease the size of the image sprite that's attached to the RigidBody2D. The problem is, it's not working. No matter how much I try to scale down, the size of the blood drop circle remains the same. const blood druple scn preload("res Scenes blood.tscn") func spawnBlood() var newBlood Blood druple scn.instance() rotationAdd rotationAdd 30 if(switchBloodSize 0) set scale(Vector2(2,1)) This part is my problem print("blood size ", newBlood.get scale()) add child(newBlood) switchBloodSize 1 elif(switchBloodSize 1) newBlood.scale(Vector2(0.5,0.5)) This part is my problem print("Blood size ", newBlood.get scale()) add child(newBlood) switchBloodSize 0 newBlood.set pos(Vector2(100,100)) rotate(rotationAdd) As you can see, I have two different if conditions, each with a different scale() and size. Sadly, both remain the same size. The strange part is that it does display the scale values as been altered, yet the newBlood instance is not visually changing. Why is this?


Is it possible to have a script built in into a custom resource? Here's a rudimentary custom resource extends Resource export(Resource) var scr I can drag a pre made .gd script into this exported property in Inspector, and it works as intended. I can click on the exported property field and embed a resource (like "New ShaderMaterial"), and it would also work as intended, and I would be able to edit that sub resource normally. However, if I click on the exported property and select "New GDScript", there doesn't seem to be a way to open the new gdscript for editing. Is it possible to embed a gdscript sub resource the same way you can embed a different sub resource?


Godot Engine Why is baking light making my scene darker? I have an interior scene with some windows. The light is from an OmniLight near the ceiling, default environmental light from outside, and a desk lamp with emission. Without baking light, the scene looks like this Consistent with the documentation for emission, the desk lamp is not affecting the surrounding objects. I want to bake the light to see the lamp's effect and to support low end hardware. I followed the baked lightmaps tutorial and set the BakedLightmap's extents to encompass the entire room. After baking, the scene looks like this I can see the lamp's light, as expected, but now everything is too dark. It is unclear to me from Godot's documentation if scenes include indirect light without baking. I have tried this with the OmniLight set to bake quot all quot and only indirect light. What am I missing here? UPDATE 10 April 2021 The problem seems to be that baking environmental light isn't working as expected. I was using Godot 3.2.3 now I'm using 3.3rc8. That gives the BakedLightmap options for environmental light, but the problem remains. I began troubleshooting by shuttering all the light sources as follows Hid the OmniLight, and set its quot Bake Model quot property to quot disabled quot Unchecked quot use in baked light quot for the desk lamp Set the default environment's background and ambient energy to 0 Set the BakedLightmap's quot environment mode quot to quot Disabled quot , verified quot Min Light quot is set to pure black, and cleared the quot Light Data quot When I run the game, I get exactly what I expect a black screen. If I bake light under these conditions, I continue to get a black screen, as expected. Here's where things get screwy. When I set the BakedLightmap's quot environment mode quot to quot Scene quot with the environment still without any light I get dim illumination.


Godot play video after file load I used WebM video in my game but it's lagging. The audio is few secs delayed then video. Is there any way to load the video first then play so that the lagging doesn't occurs


How do I attach the Visual Studio Code debugger to Godot At 3.0 Godot now supports C and encourages the use of Visual Studio Code to edit this code. It is not clear how to attach VS Code so that we an apply breakpoints and debug a project at runtime. I am running A recent build of Godot from master (b49ca94 with mono for 64 bit windows) Visual Studio Code 1.21.0 with these extenstions C 1.14 Mono Debug 0.15.8 Mono 5.10.0


How can I get the NodePath that points to the property, rotation, of the parent node? The 2nd arg in interpolate property takes a NodePath, but str of a path to a prop seems fine too. So I'd expect this to work var rotation node path " root Main Boid1 InitialRegion Bird rotation" but I'm getting the error ERROR interpolate property Condition ' !prop valid ' is true. returned false func lerp rotation() add child(tween) var rotation node path str(parent.get path()) " rotation" var current Math.smallest equal angle(parent.rotation) var target Math.smallest equal angle(target rotation) var duration 1 print(current, ' ', target, ' ', rotation node path) tween.interpolate property(parent, rotation node path, current, target, 1, Tween.TRANS LINEAR, Tween.EASE IN OUT) tween.start()


Godot Collision for character teleportation I'm currently working on a little game to discover Godot game engine. It's a Top Down game and I want my character to be able to teleport through walls. I thought to dupplicate my character's collision box and to set its position to the teleportation's position but I didn't find a way to check if there is a collision to this new position. Any advise?


GET and POST requests in gdscript How do I perform get and post requests from Gdscript in Godot? I am trying to get a map API and use it in the game.


How do I add an object to the node tree at a specific position I'm making a skiing game, and a part of that is programmatically adding snow to the scene in a specific place. It will all be the child of a single node. I was looking through the Flappy Bird code but when it instances a scene, it only uses the function add child(). There doesn't seem to be a way to set its position. Here is the project on github.


How do i get effect when gems come together in godot? I'm create gems puzzle game, In my game there is requirement that 2x2 matrix gem will group and then it will convert in power gem. check below image. I'm new in game development, so anyone can point me out ? any suggestion or link will be helpfull. Thank you


Godot tween animation playing order I'm making a three in line game with godot, but i'm having an issue. First time when swapping cells, the animation of swapping and the elimination of cells (in the case of making 3 or more cell aligned in a line) played both at the same time. So i refactored a bit the code, now i have queue for each cell that manages the animation to be played one by one. Now my problem is this, the cells that the player swaps, they do fine, the play the swap animation then the elimination animation. the problem are the other cells in the line, those get removed as the first cells are playing the swap animation first and then elimination animation. Step 1 Step 2 cells in line remove animation nothing swaped cells swap animation remove animation in case i didn't explained well i left a more graphic description of the flow of the animation steps. this is how i want the animation to be played Step 1 Step 2 cells in line nothing remove animation swaped cells swap animation remove animation I'm not sure how to solve the problem, each cell manages their animations in the queue.


Getting Parser Error The identifier "delta" isn't declared in the current scope. in godot this is the whole code extends KinematicBody signal health updated(health) signal killed() var speed 10 var acceleration 10 var gravity 0.2 var jump 5 var mouse sensitivity 0.3 var direction Vector3() var velocity Vector3() var fall Vector3() export (float) var max health 100 onready var health max health setget set health onready var head Head func ready() Input.set mouse mode(Input.MOUSE MODE CAPTURED) func input(event) if event is InputEventMouseMotion rotate y(deg2rad( event.relative.x mouse sensitivity)) head.rotate x(deg2rad( event.relative.y mouse sensitivity)) head.rotation.x clamp(head.rotation.x, deg2rad( 90), deg2rad(90)) func physics process(delta) direction Vector3() move and slide(fall, Vector3.UP) if not is on floor() fall.y gravity onready var invulnerability timer invulnerabilitytimer func damage(amount) if invulnerability timer.is stopped() invulnerability timer.start() set health(health amount) func kill() pass func set health(value) var prev health health health clamp(value, 0, max health) if health ! prev health emit signal ("health updated", health) if health 0 kill() emit signal("killed") if Input.is action just pressed("jump") and is on floor() fall.y jump if Input.is action pressed("move forward") direction transform.basis.z elif Input.is action pressed("move backward") direction transform.basis.z if Input.is action pressed("move left") direction transform.basis.x elif Input.is action pressed("move right") direction transform.basis.x direction direction.normalized() velocity velocity.linear interpolate(direction speed, acceleration delta) velocity move and slide(velocity, Vector3.UP)


How to change FPS when using a sprite sheet and AnimationPlayer? With AnimatedSprite it is easy to change FPS. Is there a convenient way to do that with AnimationPlayer?


Godot Get button node in click event not working How we can get the button reference on the event function that is connected? My connect signals never works extends PanelContainer onready var hbox container ScrollContainer HBoxContainer var btn func ready() createbutton() func createbutton() btn Button.new() btn.set name("button 1") btn.text "button 1" hbox container.add child(btn) btn.connect("toggled", self, "button toggled", btn ) func button toggled(toggled, target) print("which button ", target.get name()) if toggled true print("Button ist pressed") else print("Button is released")


In Godot browser game, is it possible to let the player download a file? I have a Godot game exported to the browser. I want to let the player export some data and let it save the data as a file on their PC, as if they were downloading a file from the Web. Is it possible for me to do that?


How signals work when Node2D is queue freed? Consider this setup KinematicBody2D (Player) Sprite (icon.png) VisibilityNotifier2D With Player.gd class name Player extends KinematicBody2D signal unvisible onready var visibility notifier VisibilityNotifier2D VisibilityNotifier2D func ready() gt void visibility notifier.connect( quot screen exited quot , self, quot on screen exited quot ) func on screen exited() gt void emit signal( quot unvisible quot ) Now I have a template Level.gd Node2D (Level) Player extends Node2D onready var player Player Player export var debug no enemy false export var debug no player true func ready() gt void player.connect( quot unvisible quot , self, quot reset level quot ) if debug no player player.queue free() func reset level() gt void print( quot reset quot ) get tree().reload current scene() The print statement proves that this setup make a kind of infinite loop of reset because the signal screen exited is still emited when the player is queue free. Is it expected? I am even more surprised with this modified version which produces the same thing func ready() gt void if debug no player player.queue free() player.connect( quot unvisible quot , self, quot reset level quot )


Godot and getting files via HTTP So, I am wanting to use Godot to get a (binary) file using HTTP and then either save it or, even better, turn it into a Resource in memory that I can use. It'll be WAV files that I'm getting in return (trying to implement MaryTTS, which is running as a server on localhost). I had a look at the docs for HTTPRequest, but can't seem to get a working solution. I do HTTPRequest.request("http ...") when a keypress is made, and I have the on HTTPRequest request completed() function, but this never seems to be called. I tried with the function in the same Node as the request (as per the docs' example), and I also tried putting it as part of a script for the HTTPRequest Node. If I hit the triggering key fast enough, it gives an error ("HTTPRequest is processing a request"), but if I do it slower, it doesn't give that error, so it appears it is finishing. It just doesn't do anything when it finishes. HTTPRequest gives a return value of 0, which I assume means no error? (Or should this give me HTTP status codes?) Any idea what I'm doing wrong? Can HTTPRequest handle binary files? How do I get this working? (Any suggestions on a better way to implement MaryTTS are also welcome).


No AA support in Godot 3.1? I'm using Godot 3.1.1 and just realized that there is no available AA options. According to some post, Godot 2 supports FXAA, but some reason it's took out from 3. So I try to get FXAA for Godot 3.1, but couldn't find any. I don't want to publish my game without Anti Aliasing. Is there a way to apply FXAA in Godot 3.1.1 which using GLES3?


How do I decrease the scale of an instanced node or scene? I'm trying to decrease size of instanced RigidBody2D scene, through code. With scale(), I'm trying to decrease the size of the image sprite that's attached to the RigidBody2D. The problem is, it's not working. No matter how much I try to scale down, the size of the blood drop circle remains the same. const blood druple scn preload("res Scenes blood.tscn") func spawnBlood() var newBlood Blood druple scn.instance() rotationAdd rotationAdd 30 if(switchBloodSize 0) set scale(Vector2(2,1)) This part is my problem print("blood size ", newBlood.get scale()) add child(newBlood) switchBloodSize 1 elif(switchBloodSize 1) newBlood.scale(Vector2(0.5,0.5)) This part is my problem print("Blood size ", newBlood.get scale()) add child(newBlood) switchBloodSize 0 newBlood.set pos(Vector2(100,100)) rotate(rotationAdd) As you can see, I have two different if conditions, each with a different scale() and size. Sadly, both remain the same size. The strange part is that it does display the scale values as been altered, yet the newBlood instance is not visually changing. Why is this?


on Tween tween completed not triggering I'm using this script to print out my text in a textbox one character at a time, and to do this I'm using a Tween. I have this set up so that when the Tween sends the tween completed signal, then the variable finished becomes true. But for whatever reason, the tween completed signal never gets sent. Does anyone see a reason that the signal wouldn't be sent? Thank you! extends Control var tempdialog 'Super Animal Racing is shaping up to be a great game!', 'Thomas is so good at programming omg!', 'Isn 't this so exciting?' var dialog index 0 var finished false var totalcharacters 0 func ready() load dialog() func process(delta) AnimatedSprite.visible finished print( quot visible quot , finished) if Input.is action just pressed( quot jump quot ) load dialog() func load dialog() if dialog index lt tempdialog.size() finished false RichTextLabel.bbcode text tempdialog dialog index RichTextLabel.percent visible 0 Tween.interpolate property( RichTextLabel, quot percent visible quot , 0, 1, 1, Tween.TRANS LINEAR, Tween.EASE IN OUT ) Tween.start() dialog index 1 func on Tween tween completed(object, key) print( quot tweentrigger quot ) finished true


Linux Mint Godot window when ran very small I am running my game on Linux Mint 20 Cinnamon. When I run my game I get a very small window that is about 1 pixel tall. This happens across all projects. I have tried uninstalling Godot and reinstalling it from the package manager. I have also tried the official launcher from their website. Updating through update manager does not help as well. I get the same issue using Godot 3.2.2 and 3.2.3


How to make a 3D mesh invisible in Godot? Just like the title says i'm trying to make the mesh disappear after a set value reaches zero. Current code is trying to simply turn the entity invisible so that later i can implement a resurrect function. if Sname get node("Entity").get name() print("punched number 1") selected.health selected.health 10 if selected.health lt 0 selected.health 0 get node("Control Button").disabled true Entity.visable false Is it even possible to toggle that value or is there an easier way to do this? I dont want to use free queue() as that would interfere with other entitys. Thanks for the help in advance, im new to Godot so sorry if this ends up being a no brainer.


How do I use get action strength in Godot? I get the error Invalid call. Nonexistent function 'get action strength' in base 'InputDefault'. extends KinematicBody2D export (int) var speed 400 export (float) var rotation speed 10 var velocity Vector2() var rotation dir 0 var stance 0 func ready() Input.action set deadzone("left", 0.25) Input.action set deadzone("right", 0.25) Input.action set deadzone("up", 0.25) Input.action set deadzone("down", 0.25) static func angle to angle(from, to) return fposmod(to from PI, PI 2) PI func get input() var left joy axis h Input.get action strength("right") Input.get action strength("left") var left joy axis v Input.get action strength("up") Input.get action strength("down") rotation dir 0 velocity Vector2() if(Input.is action just pressed("stance")) if(stance 0) stance 1 else stance 0 if(stance 0) velocity Vector2() velocity Vector2(speed, 0) left joy axis h velocity Vector2(0, speed) left joy axis v if(angle to angle(rotation, velocity.angle()) gt 0) rotation dir 1 elif(angle to angle(rotation, velocity.angle()) lt 0) rotation dir 1 else rotation dir 0 elif(stance 1) rotation dir (Input.get joy axis(0,7) Input.get joy axis(0,6)) velocity Vector2() velocity Vector2(speed, 0).rotated(rotation PI 2) Input.get joy axis(0,0) velocity Vector2(speed, 0).rotated(rotation) Input.get joy axis(0,1) func physics process(delta) get input() rotation rotation dir rotation speed delta move and slide(velocity)


Why does the kinematic body move in opposite direction after I interpolate its movement, and how do I fix it? I have added some basic movement and some manual interpolation to a cube that is a kinematic body in Godot. extends KinematicBody var speed int 10 var slowdown buffer 0.2 var movement Vector3(0,0,0) func ready() pass func interpolate() if movement.x gt 0 movement.x slowdown buffer elif movement.x lt 0 movement.x slowdown buffer else movement.x 0.0 func physics process(delta) if Input.is action pressed( quot left quot ) movement.x speed elif Input.is action pressed( quot right quot ) movement.x speed else interpolate() move and slide(movement) The problem is that when I move the cube using A and D, after the cube stops after the interpolation, it starts moving in the opposite direction with a non increasing speed. How can I fix this?


How to have a tilted FNT font on Godot? Since FNT is a bitmap font I was thinking perhaps making the padding negative to the right and left side of the characters and rasterizing each glyph already skewed by an angle could make the font appear to be tilted. Does any one know whether FNT sports negative padding or whether Godot support some form of skewing that could accomplish that? Please take a look at the image to see what I'm describing


Difference between process(delta) and physics process(delta)? The documentation is pointing one main difference, this is the concept of being synced or not with the physics engine, so the delta parameter has more chance to be constant in physics process(delta) than in process(delta). But I am pretty sure that no one counts on that. And that everybody checks the value of delta in physics process(delta). So what are the different use cases of those two functions?


How do I remove the window border in Godot? I want to show my Godot engine game in a borderless window, but not fullscreen. I want to just have the game view visible on screen with no title bar or window chrome.


How to create bullet hole decals in Godot engine? How can you create decals such as bullet holes in Godot? Godot doesn't seem to have any native method of creating decals. I am trying to create decals so that bullet holes will be displayed properly on curved and angled surfaces and corners. I have tried a few plugins, but none of them worked, they all either had a texture stretching issue or they didn't work at all. For example, when I tried using the Screen Space Decals plugin (https godotengine.org asset library asset 241), it did draw decals when a texture wasn't provided (a simple black rectangle by default), but when I assigned the bullet hole texture to the decal property the bullet holes became invisible. What would be an ideal method of creating decals in Godot?


How do I access a variable from my code in Godot's editor? In Godot, I have a node with a variable that I often need to tweak for balancing purposes. It would be a lot easier to manage if I could modify it inside the editor instead of the code. How would I go about doing this?


What is the efficient way to sync TextureProgress with a Timer not in the UI? I want to use a TextureProgress which reflects the state of a Timer. I have tried to emit signals FROM the Node2D. process() which owns the Timer with emit signal( quot time left changed quot , timer.time left) TO the UI but it seems to make huge impact on performance.


Why does this variable keep returning to its original value? In my 2D platformer game, I'm trying to create a button that, when the player or a box is on top of it, opens a door of the same color. Here is the code for the button extends StaticBody2D onready var is object on button false func on Green Button Area body entered(body) is object on button true print( quot button is down quot ) func on Green Button Area body exited(body) is object on button false print( quot button is up quot ) Code for the door extends StaticBody2D onready var is object on button Green Button.is object on button onready var door collision CollisionPolygon2D func process(delta) if is object on button door collision.set disabled(true) print( quot unlocked quot ) else door collision.set disabled(false) print( quot locked quot ) The button prints the right things at the right time, so I assume the button is working properly, but the door constantly stays (and prints) locked. How do I fix this? Edit After a bit of experimentation, I think that the problem is that is object on button keeps returning to whatever value its assigned at the start If I set it to true at the onready, it stays true. I do not know how to fix this, either.


How to add an icon to a script registered as a class? While learning Godot, the tutorial dictates how to add an icon to a class. Tutorial You may add a comma and an optional path to an image to use as an icon. You will then find your new type in the Node or Resource creation dialog. Steps taken Added a 16x16 svg file to the resources named something.svg . Created a script with a path to that icon. Added a node of that kind. I don't see that icon? Not sure why.


How to change FPS when using a sprite sheet and AnimationPlayer? With AnimatedSprite it is easy to change FPS. Is there a convenient way to do that with AnimationPlayer?


Is it better to connect signals in source code or with the IDE feature? In Godot IDE, what are the advantages and the caveats of using the visual IDE to connect signals to listerners instead of doing this var state bool onready var countdown Timer Countdown func ready() gt void state true countdown.connect( quot end quot , self, quot toggle quot ) func toggle() gt void state not state


How to get a consistent behavior for a rigid body hooked platform? Consider this platform made of RigidBody2D and PinJoint2D objects PinJoint2D setup is Softness 0 Bias 0.9 When I set the mass of the platform with high value, the structure starts to shake like this Why is this happening and how to fix that?


How to know if an overriden method calls its super method or not? Consider this situation, where a Player class inherits from a more general Actor class Actor.gd class name Actor extends KinematicBody2D func ready() print( quot I am an actor quot ) foo() func foo() print( quot I was thinking I was an actor quot ) Player.gd class name Player extends Actor func ready() print( quot I am a player quot ) func foo() print( quot I was thinking I was a player quot ) When one instantiate a player in a scene, we have this output I am an actor I was thinking I was a player I am a player How to know when a method will call its super class?


Inverse Distance Weighted interpolation between N Vector3s in Godot I have a number of Vector3s in Godot arranged in a grid, let's say they look like this (looking at them from above, with Godot Y is up) z (0,6,2) (1,5,2) (2,3,2) (0,2,1) (1,A,1) (2,3,1) (0,2,0) (1,3,0) (2,4,0) x I would like to interpolate the center Y value marked as A based on the surrounding vectors. The thing is, the center value is not bound to the grid, so it can be closer to the lower left corner for example, so I want to weight the interpolated value based on the distance to each vector. So, is there some clever trick in Godot using built in functions, or do I need to implement my own Inverse Distance Weighting code?


What are the most common ways of closing an open world? In many open world games, there are several ways to limit them. From original ones such as Desynchronisation(Assasins' Creed) to invisible walls. What are the most common ways to close open worlds?


how large should a map be in blender I'm learning blender and am wondering what size(blender units) I should be making my characters and maps. should i consider 1 blender unit as 1 inch, foot, meter or does it not not matter?


Is there any way to convert .unr file? I'd like to examine a Harry Potter game for study purposes. All of resources are fine except map file. The maps are in a .unr file format. I know it is unreal map file. Is there any way to convert .unr file to .fbx, .obj, or pskx formats? I want to open map file to 3ds max or blender.


How do I show the current view from the viewport on my map? I'm doing HTML5 Canvas development and currently have a large viewport (on the left) and a map (on the right). Like this I need to show on the map what is currently being viewed in the left. And I'm at a lost on how to calculate this. This is how I want it to be I am manipulating the main viewport via a transformation matrix. like 1, 0, 0, 1, 0, 0 This is decently common functionality in different games and apps. So I assume there are resources on how to do it. But I haven't been able to find any.


Level Map file creation and processing with OpenGL How do levels maps work in the game development world? Counter strike, which is a popular FPS that uses OpenGL as it's graphics library, has it's levels maps created as .bsp files. How do you create files like this, and use OpenGL to load them? Thanks!


How to write a custom map canvas and project coordinates on it? I am writing a game with Objective C ( xcode ) and I need to use the users location service to mark their position on a map but since I need to create my own map component, I am not able to use the Map framework. Doing this I think I need to project latitude and longitude which I receive from location framework on my custom planar canvas, this is a small part of my game but the other parts are pretty easy or could be done if I could manage to implement this part, however I dont know where to start. did anybody does it before? is it easy to create a map canvas? Any kind of hint and help or sympathy are welcome. Thanks


Generating a map in runtime for a simple top scrolling racing game I'm creating a simple top scrolling racing game. The concept is quite simple the player controls the car, which goes on a dynamically generated field with square blocks. Once the car hits a car, the game ends. My first implementation was simply to put a few random blocks in each row being generated on the top of the screen, but this does lead to maps where going through is impossible. What is the best algorithm for generating such type maps? My platform of choice is XNA and C , if that's important. EDIT Here's an illustration (pic) In this case, there's no possible way for the player to pass.


Best way to solve tile drawing in 2D side scroller? What i still can't figure out is which would be the more sane way easier and faster way to draw the map on the screen.. I mean i will use many tiles for my maps in my side scroller.. But problem is should i make the maps in whole images like one .png file for each map (Example) or should i draw the tiles by code like a for loop in c .. Which way is most recomended or where can i read about which way is the best.


What kind of environment is expected in elevated, hot areas? I'm creating an "exploration" game where the overworld map will be randomly generated. The biomes are generated using the data given by a "temperature map" , a "humidity map", and an elevation map for instance cold humidity snow, hot humidity jungle, etc The problem I'm left with is how to deal with elevated zones in hot climate. Right now it is set to the "bare" biome (the gray areas in the following pic), which I guess is supposed to mean "deserted dry land". On the other hand, elevated zones with colder temperatures is set to snow (in white), which is ok. So, how should I deal with the elevated zones in cold climate? I have several ideas but I feel that none of them works 1) set it to snow as well, but I think it would feel weird 2) set it to "bare" but I don't think it actually exists IRL or that i'd have any interesting gameplay perspectives


About online game servers and how to handle data So my question isn't about what technology to use or how to do this or that, but a more general question. I'm currently developing a action third person shooter. With elements of RPG weapon,armor upgrades and items. Players will be able to create new games or join old ones. So my question is how to create the game server that players will play in. I have two ideas on my mind. The player who made the game is the server. All data passes trough him and he send this data to the server updating the database of the players with their XP points kills deaths score and other. Or my host machine is the server, the player who made the game just will open new instance on my host and will be like client. And all players send their input data to the host, the host updates the game and send response back to client for any new changes like where is the enemy and other. And if i choose option 1 is there a chance the host to change the game content and manipulate the game results? (I think there is but i'm not sure) And if i choose option 2 isn't that raising the response time and potentially the game lag? or maybe there is another option?


How to prevent attackers from compromising multiplayer game servers? Consider a relatively small multiplayer game server, written by an individual or a small company. Some malicious user wants to boost their character stats by a factor of 100. What paths of attack might they have and what are the most important safeguards to prevent these attacks?


what is the best way to code an online multiplayer game? so i want to create a simple game that runs over a network but I am having trouble deciding what needs to be done in terms of what the server needs to do and what the clients need to do. I understand I should use UDP sockets but I am unsure how to implement it within a game and have all the clients be in sync. Should the server side have like a master copy of the game where i basically runs the game and accepts moves, plays them in itself, and then sends the current state of the object to the other clients?


Do I need to create my own or use a commercial server for the features and matchmaking options I want my game to support? So I'm developing an indie turn based game for iOS and, in coding up a Game Center matchmaking class, I'm starting to question whether Game Center is even the best choice for what I want this game to do. I need to figure out whether I need to create my own server, invest in a preexisting client or server service, or if I even need to use a server at all. If I do need to use a ready made service other than Game Center, which server would accomodate my game's needs best? I have limited resources and funds. Here is the list of features I want my game to support, ideally Turn based gameplay (a la "with Friends" and "with Buddies" games) Smart matchmaking (matching users up with other players of comparable skill achievements) Random matchmaking Facebook matchmaking Specific username matchmaking Contact list matchmaking A way to select what "type" of match you want to challenge an opponent to. (In random, smart, and Facebook matchmaking, there will be different "wagers" the player can make. e.g. "I wanna play a random opponent for 1000 points. Now, I wanna play my Facebook buddy for 1,000,000 points." There will be a predetermined range of amounts you can play for. It won't be customizable.) Buddies list capability (Game buddies, as opposed to contacts and Facebook) A higher concurrent game cap than Game Center offers (which I still can't really find a straight answer on) Scalability (it should support 2 or 20,000,000 players) Objective C compatibility Flexibility (for all the stuff I haven't thought of yet) Am I dreaming, here? Is there even a service that can handle all of these features? Do I need to invest months in learning a networking language to build my own? If so, how much would I need to spend on hardware? I've been looking around all morning and, so far, the only seemingly viable option is SmartFox. Under "Everything and the kitchen sink" section here, it says they support "virtual world with Zones, Rooms and RoomGroups, create complex game challenges, send invitations, manage buddy lists, create custom permission profiles, oversee the security aspects and tons more." http www.smartfoxserver.com overview platform Is there an option that Im just overlooking? Thanks for any help anyone can provide. Sorry for the long poast. One last question Does anyone know which server Dice with Buddies uses? I was experimenting with how many concurrent games I could get going and my ADHD kicked in at about 80 games. 80 concurrent games would be great for my game, but again, I need the other features I mentioned too. Thanks again.


How should I implement lag compensation in my racing game? I've looked around and I see a lot of discussion about lag compensation for FPS's, but none for racing games. I know Mario Kart uses some sort of interpolation for other racers, but it doesn't provide very smooth results a lot of the times, when the simulated kart goes way off course and then teleports back on track with the next server update. I think games like Forza also use interpolation, but the cars in games like that move a lot more predictably, so it doesn't seem noticeable. If I'm going for a game with the same type of chaotic movement that of Mario Kart, will I just have to accept that there will be sudden visible teleporting when a player has a bad connection to the server?


Saving game data to server What's the best method to save the player's data to the server? Method to store the game saves Which one of the following method should I use ? Using a database structure(e.g.. mySQL) to store the game data as blobs? Using the server hard disk to store the saved game data as binary data files? Method to send saved game data to server What method should I use ? socketIO web socket a web based scripting language to receive the game data as binary? for example, a php script to handle binary data and save it to file Meta data I read that some games store saved game meta data in database structures. What kind of meta data is useful to store? Edit 1 This question was to actually see what technology is better to use based on the situation. The situation is a game that will be on cross platform, save game throughout the cloud. Method of delivery from game client(iOS, Android, Windows Phone 8, etc..) to game server(Linux, Windows, etc.) Im using a Ubuntu server at this moment. Method of storage of binary data Inside a database system or file system. The up and down side to it and the community options of existing structures. Storing of meta data Well, I'm not too sure about how to store saved game data to server at the moment. Thus, was wondering if the community can provides tried and tested methods used by the community. and their preferences.


How do I write a game server with single threaded networking? I want to write a game server with one thread for clients message handling and use something like epoll to accept network messages. All I O and database access will be processed in a thread pool and they are asynchronous and non blocking. Given such a scheme, how should I handle other events messages (physics, game logic, etc)? Can I implement methods to handle these messages as a blocking interface in the main thread? What simple, popular servers exist (using Cocos d Unity as client) that I could look at for an example of this?


How to split login and game logic when writing servers? I'm building a poker like game server, I was going to have all logins and game logic to be handled on one server, but from my research on the web, I learn that this would not scale, and it would make sense to split the work into a login and game servers. But what I don't get is after I handled authentication in the login server, and have the client make a new connection to the game server, how would I know which client is which? Would I not have to re login again and thus defeat the purpose of having a server for login? Is there some way to pass a connection across processes and machines that I don't know about? Excuse my little knowledge of networking.


When to read write to database with a game server My question is fairly simple but maybe hard to answer. I'm currently building my own game server and I've done to login server now. So, on to the actual game server. I have a question for this server though. Say, a thousand players are moving around on this server, how do I manage this with the database (MySQL) that should hold the player positions and such? I understand I can't query the database every time something small changes or a single player moves because that would be a huge load for that server. How is this done in real game servers? When do they read or write to the database?


Choosing a server for a PVP game So I am starting a game with a friend as a small project, and we are considering what game servers would we need. Firstly, the game is a multiplayer(player vs player) game, for example, like an online chess game. However it is real time, so the latency cannot be too high. The players basically take turns, but in a real time fashion. The platform is going to be Android (and perhaps extend to iOS in the future) The server would need to synchronize the players' moves to each other devices. I don't really need anything large scale and I am thinking of using PHP since the volume of data isn't really that big, this is like a web based game with a requirement of a slightly lower latency. What would be the advantages and disadvantage of using Apache PHP for a game like this? If that seems to be a bad choice, I would be grateful if you can share your experience with me. Thank you. (We are both programmers and we are familiar with Java C Obj C Apache PHP Tomcat JSP Javascript)


how does server communication work in a flash game with a php backend I am trying to create a browser game using actionscript flash. Currently, I'm trying to understand how I would go about creating a back end which interfaced with my MySQL database. As far as I understand, If I create a php file on a webserver called test.php and then navigate to a webpage hosted on the server eg. www.example.com test, the php script will run and display the result in my browser. This would use http. Is this how communication between client and server usually works in a flash game? for example, if the game needed to query the db. Would actionscript have to essentially invoke the url of the php script that would execute the query? it could then parse the data and use it. If this is the case, then is JSON considered a good way to transfer data over http?


Where should I place input output console for server? I'm developing a simple 2d online game and now I'm designing my server. The server will be run on linux vps and I need a way to communicate with it (for example to close it, and as it will be run on vps, simply closing terminal won't work). So I think there are 2 options 1) Write 2 apllications server which doesn't say anything and doesn't accept console input and the second application is console which sends commands to server (like exit, get online players etc). 2) Have 2 threads on the server appplication one is the real server, the second thread will be used for cin and cout. However I'm not sure if this will work on vps... Or maybe there is better aproach? What is the usual way of doing this?


How does an Engine like Source process entities? On the Source engine (and it's antecessor, goldsrc, quake's) the game objects are divided in two types, world and entities. The world is the map geometry and the entities are players, particles, sounds, scores, etc (for the Source Engine). Every entity has a think function, which do all the logic for that entity. So, if everything that needs to be processed comes from a base class with the think function, the game engine could store everything on a list and, on every frame, loop through it and call that function. On a first look, this idea is reasonable, but it can take too much resources, if the game has a lot of entities.. So, how does a engine like Source take care (process, update, draw, etc) of the game objects?


Ways to persist entities and components in an ECS? I am working on a small multiplayer game with rpg elements using java and quot Artemis ODB quot . Most of the logic is already done but one important thing is missing. The persistence. So i am searching for different ways to persist my game. One thing is important, the world is huge and i cant load in the whole world at once. I already stumbled upon two different ways on my own. Using a relational database or a nosql database. But one thing scares me... entity references. In my game i have an player entity and item entities. The player entity owns a inventory component which stores a reference to some item entities. In my ecs, each entity reference is an simple integer. So this looks like this... Represents the Inventory of our game, contains references to entities acting as items. public class Inventory extends HibernateComponent public Set lt Integer gt itemEntities new LinkedHashSet lt gt () Why does this scare me ? Well... Entity references are Integers in my case. They are no real ID and i cant set or change this quot ID quot of an entity because my framework permits it. This brings us straight to the problem. When i serialize this component or the whole player entity it would look like this. Inventory itemEntities 40,2,5,50 So when we save this and load it later on we have no entity with the id 40... and even if we recreate that entity we cant set it to an id of 40, because the frameworks permits it. So how the heck do we save references between entities ? So all in all... what are common ways to save, load entities from an ecs ? How do you do it ? And what would you recommend ?


Should components in Entity Component System pattern have logic? Is often read that in entity component system pattern we should treat components just as a passive data structure with no logic at all, this way we follow to a data oriented design approach with efficient usage of cache memory and gain performance. I was developing a simple game using this rule and when the game was getting bigger I start facing some serious code smells such as repeated code in systems, let's suppose its a shooter to illustrate an example. In this shooter I had bullets being fired so I created a BulletComponent and a BulletSystem that handles when it collides and make some damage and if don't collide with anything the bullet dissapear in five seconds. Then I wanted some explosives so I created the ExplosiveComponent and ExplosionSystem, once the explosive is placed it explodes in ten seconds. At this point we can notice the first repeated code between systems then we can make an abstraction and we create a DurationComponent and a DurationSystem so the bullet and the explosive contains it with the time it should last.Then I realized that when the explosive should explode I want to create some particle effect in the area so this abstraction is no longer valid as I want to perform differents actions when time runs out, but if I do as at the beginning I have the repeated code between systems (ugh!). This example is simple but I'm facing this with more complex things like AI, or reacting to collisions. One solution I came to this is that I really wanted an ActionComponent with a ActionSystem that executes the action contained in the component but this way I'm breaking that components only contains data and they should not have logic! this is more an 'hybrid' approach. But if you start thinking deeply the ActionSystem is very generic and you can almost do anything with it so it's hard to determine whether a system is necessary or not. The same can be applied to collisions, instead of having lots of systems with logic for different entities colliding, you can just have a CollisionHandlerComponent with the logic on it for each entity. I found the following advantages making generic systems like this Higher flexibility (you can customize each entity easily) No repeated code Less systems (more performance?) But as I said the main disadvantage is that is really confusing if a system is needed as you can stick logic to components. Is it wrong to follow this sort of hybrid ecs? If yes, what would be your approach to the example without repeating code in systems?


Should fields in components in an ECS use polymorphism? I've just started to try and learn how to use ECS (Entity component systems), but I'm having trouble understanding the concepts behind components. Should adding more types of components, or trying to make a component reusable through its fields be favored? For example, if I'm trying to give all entities a shape for collision detection, should I have a different component for every shape (RectangleComponent, CircleComponent, PolygonComponent), or should I have one ShapeComponent, and in there have a field which is of type Shape, with class Shape having subclasses Rectangle, Circle, and Polygon. I'm unsure because using a Shape seems to be much more flexible and easier to implement systems, but it also feels like I'm violating the ECS rule of not having any functionality in components.


Defining collision response in an Entity system I'm building a really simple top down 2d shooter which uses an Entity Component pattern. I've added several different entities to a level and given them different collision groups. I have an entity to represent a teleporter (assigned to collision group A), a player entity (group B), and a bunch of enemies (Group C). I understand that the actual collision response should be decided in the collision System based on the groups that the colliding entities belong to. What I can't figure out is how to define the specifics of a collision. For example, if a player collides with a teleporter I need to move the player across the level. Where do I store the target location? I'd assume in a component on the teleporter. Should I create a whole new component just for that data? I feel it should be stored in the teleporters collision component but no all entities that use the collision component will require this data. Could someone please try to enlighten me? Thanks


User friendly scripting when using an ECS? I am currently creating a small hobby project to get back into game development, and I have decided to structure my entities using an ECS (Entity Component System). This implementation of an ECS is structured like so Entity In my case it's a unique int identifier that is used as a key to a list of components. Component Holds only data, e.g. the Position component holds an x and y coordinate, and the Movement component holds a speed and direction variable. System Handles components, e.g. it takes the Position and Movement components and adds the speed and direction to the position's x and y coordinates. This works fine, but now I wish to implement scripting into my games, in the form of a scripting language. In previous projects I've used an OOP implementation of game objects, which meant that scripting was pretty straight forwards. For example, a simple script could look something like this function start() local future entity moveTo(pos1) wait(future) local response entity showDialog(dialog1) if wait(response) 1 then local itemStack entity getInventory() removeItemByName("apple", 1) world getPlayer() getInventory() addItemStack(itemStack) else entity setBehavior(world getPlayer(), BEHAVIOR HOSTILE) end end However, when using an ECS, the entity itself does not have any functions like moveTo or getInventory, instead the above script written in ECS style would look something like this function start() local movement world getComponent(MOVEMENT, entity) movement moveTo(pos1) local position world getComponent(POSITION, entity) local future Future untilEquals(position.pos, pos1) wait(future) local dialogComp world getComponent(DIALOG, entity) local response dialogComp showDialog(dialog1) if wait(response) 1 then local entityInventory world getComponent(INVENTORY, entity) local playerInventory world getComponent(INVENTORY, world getPlayer()) local itemStack entityInventory removeItemByName("apple", 1) playerInventory addItemStack(itemStack) else local entityBehavior world getComponent(BEHAVIOR, entity) local playerBehavior world getComponent(BEHAVIOR, world getPlayer()) entityBehavior set(playerBehavior, BEHAVIOR HOSTILE) end end This is a lot more verbose compared to the OOP version, which is not desirable when the scripting is aimed towards mostly non programmers (players of the game). One solution would be to have some sort of wrapper object that encapsulates an Entity and supplies functions such as moveTo directly, and handles the rest internally, although such a solution seems sub optimal since it takes a lot of work to cover all the components, and every time a new component is added you would need to change the wrapper object with new functions. To all game developers that has implemented scripting in an ECS before how did you do it? The main focus here is usability for the end user, with as little "maintenance" cost as possible (preferably you don't need to change it every time you add a component).


Organizing an entity system with external component managers? I'm designing a game engine for a top down multiplayer 2D shooter game, which I want to be reasonably reuseable for other top down shooter games. At the moment I'm thinking about how something like an entity system in it should be designed. First I thought about this I have a class called EntityManager. It should implement a method called Update and another one called Draw. The reason for me separating Logic and Rendering is because then I can omit the Draw method if running a standalone server. EntityManager owns a list of objects of type BaseEntity. Each entity owns a list of components such as EntityModel (the drawable representation of an entity), EntityNetworkInterface, and EntityPhysicalBody. EntityManager also owns a list of component managers like EntityRenderManager, EntityNetworkManager and EntityPhysicsManager. Each component manager keeps references to the entity components. There are various reasons for moving this code out of the entity's own class and do it collectively instead. For example, I'm using an external physics library, Box2D, for the game. In Box2D, you first add the bodies and shapes to a world (owned by the EntityPhysicsManager in this case) and add collision callbacks (which would be dispatched to the entity object itself in my system). Then you run a function which simulates everything in the system. I find it hard to find a better solution to do this than doing it in an external component manager like this. Entity creation is done like this EntityManager implements the method RegisterEntity(entityClass, factory) which registers how to create an entity of that class. It also implements the method CreateEntity(entityClass) which would return an object of type BaseEntity. Now comes my problem How would the reference to a component be registered to the component managers? I have no idea how I would reference the component managers from a factory closure.


How should one component "trigger" another one in a component system? In my game I have a MoveComponent and a ClimbComponent. Some characters can only move around on one level, others are able to climb to the next floor. My intention is to have characters randomly be able to climb if the are about to bounce into a wall. How would I manage this? Should the ClimbComponent be added dynamically and also be removed again, or should random characters always have the ClimbComponent and it would be activated and deactivated dynamically?


Handling movement using an Entity Component based System Architecture I have seen various descriptions of how to handle movement in a component based entity framework. The most common I've stumbled across is the idea of using components called Controller, Physics, Transform, Velocity, and Collider. The idea here is that the Controller influences the Velocity component when movement keystrokes are detected. The Velocity component in turn influences Physics. Once the simulation has been stepped, the Collider is either affected if a collision occured or is not if no collision happened. In the end, the Transform is updated with the new position from the physics simulation step and thusly the Renderable needs to be adjusted so it is drawn in the proper location. I have often read that one needs to consider both physics driven and non physics driven entities. As outlined in the above paragraph, manipulating physics driven entities seems like a piece of cake. The difference with non physics driven entities is that the Velocity component values need to simply be applied to the the Transform based on delta time. This would allow moving the entity without being concerned with physics nor collision detection. For physics driven entities, one simply iterates entities with both Velocity and Physics components. But for non physics driven entities, simply iterating over entities with a Velocity component isn't sufficient as it would include the above subset as well. So there must be some factor that clearly separates these two cases. So with these two cases in mind, how would movement actions that influence the values of Velocity be carried out in such a system to manipulate both types of entities whether physics plays a roll in their movement or not?? And lastly, considering that there may be times where the transform for an entity needs to be manipulated directly, such as player clicking on a portal to be teleported to another x y z position, how would one properly propagate this change to adjust both the physics step simultation and the renderable's draw location? EDIT bobenko Your explanations provide insight to the most common case where objects are simulated via physics but I'm somewhat lost on the Kinematic aspect regarding updating an entities position via a velocity value? Are you simply implying that some code of my own will apply movement to the entity via velocity, thus being Kinematic? I still am interested in your explanation on how to avoid cyclic notifications effectively when aspects of these components involved change. For all who answered, I'm still not clear how would you handle teleporting an entity from one position to another? Would this involve turning off physics, teleporting the player, then turning physics on after teleport finished? Turning physics on off can be as simply as setting the entity as Kinematic YES NO, right?


Whats the most efficient method for controlling entities? I'm creating a tower defense game and I'm having logistical issues trying to figure out how to best have all of the enitites do their apporiate task. I have considered just constantly looping through a list of all the game entities calling a onAction() method, but I'm not sure if that is effective. I have also considered having each entity be a thread, but when I am dealing with hundreds of entities, some of which don't need thread time, I'm back to square one. Can I get any suggestions on a solid approach? Am I on the correct track with my first idea? Thanks for any help Aedon


Communicating with Collision System in ECS I have read tons of articles and forums threads about ECS but still can't understand how anything in engine should communicate with Collision System. Let's say I have Input System that handle keyboard input and then at some point it want to move player character forward. Before doing this I should ask Collision System if there would be a collisions after that move and only if no change position. My current approach is to have requestTranslation function in CollisionSystem that take translation function and object like this moveForward() V3.CollisionSystem.requestTranslation(this.mesh, function(object) object.translateZ( this.movingSpeed) .bind(this)) What do you think about this approach? How good bad it is? What are know alternatives?


Intersystem communication in a ECS game Apologies if this question has been answered before, but after relentless searching I couldn't find anything. As many, I've recently jumped on the ECS bandwagon, and I am currently killing some time by making a modest ECS game. The game is a somewhat simple 2D platform game. It is programmed in plain JS. The layout of the game is essentially as following The core of the game is the Engine, the Engine runs the game loop and holds an EventManager, responsible for raising events, and an EntityManager, responsible for containing all components of all entities. All logic is done by systems. The systems registers event handlers (i.e. member functions) with the EventHandler for specific EventTypes, which gets called when an event of that type is raised. For example this.eventManager.registerHandler(EventType.EVENT RENDER, this.render, null, this) I recently switched from calling all systems relevant functions explicitly in the Engine to this pattern. But over to my problem and question. For rendering I have a RenderSystem. This system contains references to several type of drawable animatable components which it, you guessed it, renders. Until recently, this system also contained a reference to another system, MapSystem, which spatially indexes all entities. The reason for this reference was to be able to call a function along the lines of mapSystem.search(frame bound) effectively pruning away all entities not needing to be rendered. So I have a couple of questions regarding this Is it very bad practice for systems to communicate directly? Something about it just doesn't smell right to me. I see how it might severely complicate your code if you have say 100 systems, and each system holds references to many of the other systems. Hello O(n 2). If I am not to hold inter system references, how do I perform communication like described above? My initial thoughts was to create an entity whose primary purpose were to hold the necessary information (i.e. all entities currently in the frame). Then let MapSystem write to and RenderSystem read from this entity. But this also seems to be rather unclean to me. Especially as MapSystems search function might be useful to call in many different contexts. Creating an entity per calling context doesn't really seem like a good way to go about it either. TL DR Is it bad for systems in a ECS game to communicate directly and hold references to each other?


Entity polymorphism and entity attributes I want to design the entity system of my game in a way such that entities are modular, easily modified without affecting other entities, and finally easy to add new types of entities. So ideally some version of component based design. In some parts of the code I want to deal with entities generally and abstractly, for example "update all entities" and "render all entities", however in other parts I want to deal with specific types of entity, like when a Soldier entity is fighting a Tank entity. The problem is some entities need attributes which others do not. For example a soldier needs HP but a missile do not. How do I keep entity attributes modular, and avoid adding every attribute in the game to the Entity object?


Efficiently separating Read Compute Write steps for concurrent processing of entities in Entity Component systems Setup I have an entity component architecture where Entities can have a set of attributes (which are pure data with no behavior) and there exist systems that run the entity logic which act on that data. Essentially, in somewhat pseudo code Entity id map lt id type, Attribute gt attributes System update() vector lt Entity gt entities A system that just moves along all entities at a constant rate might be MovementSystem extends System update() for each entity in entities position entity.attributes "position" position vec3(1,1,1) Essentially, I'm trying to parallelise update() as efficiently as possible. This can be done by running entire systems in parallel, or by giving each update() of one system a couple of components so different threads can execute the update of the same system, but for a different subset of entities registered with that system. Problem In the case of the shown MovementSystem, parallelization is trivial. Since entities don't depend on each other, and don't modify shared data, we could just move all entities in parallel. However, these systems sometimes require that entities interact with (read write data from to) each other, sometimes within the same system, but often between different systems that depend on each other. For example, in a physics system sometimes entities may interact with each other. Two objects collide, their positions, velocities and other attributes are read from them, are updated, and then the updated attributes are written back to both entities. And before the rendering system in the engine can start rendering entities, it has to wait for other systems to complete execution to ensure that all relevant attributes are what they need to be. If we try to blindly parallelize this, it will lead to classical race conditions where different systems may read and modify data at the same time. Ideally, there would exist a solution where all systems may read data from any entities it wishes to, without having to worry about other systems modifying that same data at the same time, and without having the programmer care about properly ordering the execution and parallelization of these systems manually (which may sometimes not even be possible). In a basic implementation, this could be achieved by just putting all data reads and writes in critical sections (guarding them with mutexes). But this induces a large amount of runtime overhead and is probably not suitable for performance sensitive applications. Solution? In my thinking, a possible solution would be a system where reading updating and writing of data is separated, so that in one expensive phase, systems only read data and compute what they need to compute, somehow cache the results, and then write all the changed data back to the target entities in a separate writing pass. All systems would act on the data in the state that it was in at the beginning of the frame, and then before the end of the frame, when all systems have finished updating, a serialized writing pass happens where the cached results from all the different systems are iterated through and written back to the target entities. This is based on the (maybe wrong?) idea that the easy parallelization win could be big enough to outdo the cost (both in terms of runtime performance as well a code overhead) of the result caching and the writing pass. The Question How might such a system be implemented to achieve optimal performance? What are the implementation details of such a system and what are the prerequisites for an Entity Component system that wants to use this solution?


ECS, databases, XML and serialization My entity component system engine is coming along quite nicely I have two very different apps working on the same executable. (One 2 d scroller, one 3D Asteroids type game). In the interest of getting something working, I've been creating XML definitions of the games, and editing them using a small custom tool that does little more than ensure that I don't add components that don't exist, and that the files are valid XML. I'm at something of an apex or flection point in that the tools and process I'm using really aren't suitable for production. Hand editing large XML files is an error prone, painful process. (JSON is well supported and pithy, but still requires visual syntax checking.) I could switch to a database such as SQLite, but I have yet to find a good graphical interface (something along the lines of SQL Server Management Studio would be nice). Are there any COTS tools that can ease this process? I found a C SQLite implementation with a basic ORM, but it doesn't support complex types like Vector3 or Rectangle. I can serialize these into strings or edit the ORM code to support those types, but then I wind up with my own branch of an OSS component which invites maintenance headaches further down the road. Another thought was to just do everything in SQL Server and generate the XML from there, and have a tool that keeps the DB schema in sync with the component types in my engine, which is similar to using an ORM. What's a good solution for this problem? I've read that bigger studios (as in, more than one guy) build their own tools for this kind of thing. I can do that, but I'd really rather be writing my game than building a tool set that only I will ever see. To clarify how do those that use entity component system engines create and maintain their data that defines the game?


How can I efficiently implement a bitmask larger than 64 bits for component existence checks? In my ECS implementation, I use bit wise operations (as described and illustrated in this thread) to tell an entity what type of components it currently consists of. So my Entity class has the following member unsigned long m CompMask The different component types are then defined as an enum, whose member values are all power of two enum ComponentType COMP TYPE UNKNOWN 0, COMP TYPE PERSON 1, COMP TYPE RENDERABLE 2, COMP TYPE MOVEABLE 4, ... Each time a new component is added to my entity instance, I do the following bit operation to update the mask (where newType is a member of the enum mentioned above) m CompMask newType This approach enables me to efficiently check if a certain entity instance has a certain component (and hence might be relevant for a specific system), like so return (m CompMask amp type) The limiting factor in this approach however is the m CompMask variable since it won't be able to handle more than 64 component types (if I increase it to unsigned long long). I don't expect to be needing more than that in my current project, but nonetheless I'd like to hear some ideas regarding alternatives that allow more than 64 types (as big games certainly need to) while still maintaining the ease and efficiently of those bit wise operations as much as possible? Any ideas how this is handled in "proper big" projects?


Superclassing RPG Game Entities I am in the design process of an RPG game and I have no experience at all in game dev. This question is about how I should approach entity management using OOP classes. My train of thought is as followed Have Entity interface with basic update() function "Mortal" class and "NPC" class implement Entity "Hero" and "Monster" class inherit from "Mortal" class In this case, Mortal class are all those entities that have statuses such as HP and MP. NPC are self explanatory. I am sure my approach is naive so I would like to know the pros and cons and what would be a better way to approach this.


System function in entity component architecture I started working with ECS and I am not completely sure that I understand it correctly. As I see it now systems can implement logic for collision, movement, similar things like that. But would it be correct to dedicate a system for digging game logic only? It has a method for dig action, it also sets animation component to play "dig" animation and listens for event about animation completion after which it executes dig action. Am I doing it right?


How can I provide attribute extensibility in a component based entity system? This question and its answers move against utilizing an entity component system where the component itself is just a generic class with an dynamic container for the attributes properties of the component. Some definitions for this thread Entity ID collection of components Component Container (std map lt attribute name, attribute value gt ) of attributes properties, such as health, age, name, gender, etc. I understand and am aware of the drawbacks (no compile time type safety, added overhead of looking up values from the container). Nonetheless, I currently am working on with such a system, with the following argument, which I would now like to put to the test data driven design. If all the attributes of the component are in a dynamic container, it is very easy (in fact possible at all) to add new ones later on, outside of the source code. So you can easily script new attributes later on. And dumping saving the state of the component is a piece of cake. Compared to the proposal in the above mentioned thread, I also have an own class for each component, to implement some basic behavior and helper methods directly in them (but those also need to look up their values from the container). Example My component base class has a map for all the attributes property typedef std map lt std string, PropertyBase gt PropertyMap So an actual component looks something like the following. In the constructor I populate the attributes I want the component to have, by adding them to the map. Later I can read and update them if needed, but always with a performance penalty, since I first have to find them in the std map. class Person public ClonableComponent lt Person gt public Person(ComponentFactory const pFactory, ComponentType type, ComponentID id, GameEntity const pEntity) ClonableComponent(pFactory, type, id, pEntity) General addProperty(new Property lt int gt ("age", PROP INT, 0)) addProperty(new Property lt String gt ("gender", PROP STRING, "unknown")) addProperty(new Property lt String gt ("currentLocation", PROP STRING, "unknown")) Feelings addProperty(new Property lt bool gt ("isTired", PROP BOOL, false)) addProperty(new Property lt bool gt ("isHungry", PROP BOOL, false)) addProperty(new Property lt bool gt ("isThursty", PROP BOOL, false)) void enterLocation(GameEntity pLocGE) if(pLocGE gt hasComponent(COMP TYPE LOCATION)) updateProperty("currentLocation", pLocGE gt getName()) updateProperty("casinoEnteredDateTime", (int)std time(0)) void leaveLocation() updateProperty("currentLocation", std string("unknown")) However, that thread made me think, and I am now doubtful that my approach will work well in the long run (maintenance, scaling and performance wise) and I am therefore considering moving to an directly typed approach with no look up overhead. At the same time I don't want to loose that data driven extendability. I thought of a hybrid approach Keep all known variables as actual language variables but also add a container (std map) for scripted data driven variables. Therefore I'd know that my internal access is very fast and only the later added scripted extension would have the slow look up and the other mentioned penalties. Question What do you use would propose as an approach for a data driven ECS in terms of attribute storage handling? How do you keep it extendable? Would you recommend such a hybrid approach (real variables internally, container for new, external definitions)?


Should I load scenes from files, or hard code them? In a game engine I'm working on, I'm using scenes similar to what you would find in Unity. The entities, in my game, are composed of reusable components and custom data which is linked to those components. Entities have children, and one parent. This is shown, below class Entity ...custom data here... let parent Component var children Component var components Component ...methods... If the entities did not have custom data, then creating a scene would be described by the following steps Loading a file into memory. Creating a tree of entities. Adding components to them, with parameters listed in the file. However, this does not leave room for custom data. My other alternative is to create a scene by creating a scene object, then hard coding the entities in. It would look something a bit like this var opening scene Scene() opening scene.addEntity(Player()) opening scene.addEntity(Car()) opening scene.addEntity(Terrain()) ... The downside to this is that everything is hard coded. What can I do to create scenes in a game more efficiently?


Central logic in entity component architectures I've build a architecture based on the entity component system idea. So I got Components Just store Data Systems Operates isolated on Components Scripts Which are just objects from type Script and attached to a ScriptComponent. A ScriptSystem will execute the init() and update() functions on the scripts then. However, I'm wondering where to place the central game logic since the I have to check a few things about the overall game process, holding the map, counting the points, checks the points if they are enough for the end screen, etc. ... Should I create a single entitiy with just such a script attached to it or are there better solutions out there?