Implementing Speech Bubbles
by Gordon Marsh · in General Discussion · 07/11/2006 (6:05 pm) · 15 replies
Guys,
I'm having a go at implementing speech bubbles by using billboards above my players heads.
While there are a lot of complicated bits with this, I have a rather basic problem. At the moment the bubbles are basically updated by a player hitting a key, and that key being mapped in default.bind.cs which forwards a letter to the bubble update method.
This seems like a very inefficient way to do things. Is there a resource anyone knows of which may help me? I am thinking that I need a new non-GUI class that listens to the keyboard and can pass my bubbles a string.
Any other ideas gladly recieved!!!
Thanks,
Gords
I'm having a go at implementing speech bubbles by using billboards above my players heads.
While there are a lot of complicated bits with this, I have a rather basic problem. At the moment the bubbles are basically updated by a player hitting a key, and that key being mapped in default.bind.cs which forwards a letter to the bubble update method.
This seems like a very inefficient way to do things. Is there a resource anyone knows of which may help me? I am thinking that I need a new non-GUI class that listens to the keyboard and can pass my bubbles a string.
Any other ideas gladly recieved!!!
Thanks,
Gords
#2
Pulling ideas off the top of my head (which is better than the other end)... Could one adapt the player name display to display chat bubbles instead?
Would that be GuiShapeNameHUD?
07/14/2006 (8:58 pm)
Yeah, this is a stumper for me... I haven't had to implement anything of the sort.Pulling ideas off the top of my head (which is better than the other end)... Could one adapt the player name display to display chat bubbles instead?
Would that be GuiShapeNameHUD?
#3
...Well, a snap to someone who knows what they're doing. For me, it would take a couple weeks. =D
07/14/2006 (9:01 pm)
Whup! Look at that... nailed it on the first guess. Check out this resource by Dreamer. It should be a snap to adapt this to display a graphic bubble and a blurb of text....Well, a snap to someone who knows what they're doing. For me, it would take a couple weeks. =D
#4
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=9805
to get the bubbles going. Which, I have done to a certain extent, but I find the code a little tricky to manipulate, was getting a lot of memory issues, and am still seeing some odd flickering effects. It's also beyond me as to how to draw a bubble around the text!
Would this GUIShapeNameHUD be visible to all players... or is it just rendered on the client machine?
I'm a bit loathed to go back and start again, but this GUIShape thing looks a lot more flexible.
07/15/2006 (5:06 am)
Guys, I was actually following this resource:http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=9805
to get the bubbles going. Which, I have done to a certain extent, but I find the code a little tricky to manipulate, was getting a lot of memory issues, and am still seeing some odd flickering effects. It's also beyond me as to how to draw a bubble around the text!
Would this GUIShapeNameHUD be visible to all players... or is it just rendered on the client machine?
I'm a bit loathed to go back and start again, but this GUIShape thing looks a lot more flexible.
#5
guiShapeNameHud is wonderful for this kind of thing.
07/15/2006 (5:20 am)
It's just rendered at the client machine.guiShapeNameHud is wonderful for this kind of thing.
#6
07/15/2006 (5:56 am)
Hi Stefan... is that rendered on all client machines?... i.e. if I set the text above my players head to "hello" rather than playername, will it be rendered on ALL clients as "hello"?
#7
You need a text inpur field, which sends a command to the server to pass the text typed on it. The server must forward this text to all clients, alongside with the ghost id of the player that should be talking, so you can figure out where to place the bubble on the screen (do a good readong on how to use getGhostID() and resolveGhostID() to do this).
07/15/2006 (7:43 am)
Gordon, the recommended approach to update speech bubbles in a multiplayer environment is using commandToClient and commandToServer combos. I suggest you do a search and read on how to use them, if you don't already.You need a text inpur field, which sends a command to the server to pass the text typed on it. The server must forward this text to all clients, alongside with the ghost id of the player that should be talking, so you can figure out where to place the bubble on the screen (do a good readong on how to use getGhostID() and resolveGhostID() to do this).
#8
the answer is yes, everyone will see "hello" above the player's head *if* you set that text on the server.
here's some example code which is maybe the quickest and dirtiest way to get something like that going.
note that this is sort of messed-up because that text is commonly regarded as the player's Name!
but if this seems like a workable mock-up for you, then you could dig into GuiShapeNameHud and maybe modify it to show text without replacing the playername. anyhow:
client-side
server-side
.. and that should do it.
to use it, create a text input field as Manoel suggested,
and on carriage return simply call setChatLine() with the text.
07/15/2006 (9:18 am)
W/r/t your previous question about the player name,the answer is yes, everyone will see "hello" above the player's head *if* you set that text on the server.
here's some example code which is maybe the quickest and dirtiest way to get something like that going.
note that this is sort of messed-up because that text is commonly regarded as the player's Name!
but if this seems like a workable mock-up for you, then you could dig into GuiShapeNameHud and maybe modify it to show text without replacing the playername. anyhow:
client-side
function setChatLine(%text)
{
commandToServer(setChatLine(%text);
}server-side
function serverCmdSetChatLine(%client, %text)
{
if (!isObject(%client.player))
{
error("no player in client" SPC %client);
return;
}
%client.player.setShapeName(%text);
}.. and that should do it.
to use it, create a text input field as Manoel suggested,
and on carriage return simply call setChatLine() with the text.
#9
This is game programming, nothing is automatic. If you send the string to all the clients, then of course all of them will render it. If you send it to just one, only that client will render.
You'd have to go into the source to actually make a bubble happen and a seperate text field within it.
I suggest you take a look at guiShapeNameHud and the following sections, where all the magic happens:
Edit:
Basically, guiShapeNameHud already renders text. Duplicate that functionality, and draw a bitmap behind the text (see guiBitmapCtrl) then align it and - whoala. It's all in there already, just in pieces and scattered :/
07/16/2006 (1:01 pm)
@Gordon:Quote:
Hi Stefan... is that rendered on all client machines?... i.e. if I set the text above my players head to "hello" rather than playername, will it be rendered on ALL clients as "hello"?
This is game programming, nothing is automatic. If you send the string to all the clients, then of course all of them will render it. If you send it to just one, only that client will render.
You'd have to go into the source to actually make a bubble happen and a seperate text field within it.
I suggest you take a look at guiShapeNameHud and the following sections, where all the magic happens:
Edit:
Removed. This is a Torque forum. You'd have to take this to the Torque Private forum. This is the downside of posting in the wrong area.
Basically, guiShapeNameHud already renders text. Duplicate that functionality, and draw a bitmap behind the text (see guiBitmapCtrl) then align it and - whoala. It's all in there already, just in pieces and scattered :/
#11
So in my variant of guiShapeNameHud I added the following lines:
[removed]
This paints a white rectangle in the position that I want, but doesn't paint the bitmap. Any ideas?
Is there anything odd about dglDrawBitmapStretch in that you can't use transparent colours or the pics have to be under a certain size or whatever?
Thanks, TheGords
07/19/2006 (5:37 am)
Guys, after a bit of a battle I pretty much have this sorted out now. Just to finish it off though I was hoping to stuff a "bubble" picture behind the text.So in my variant of guiShapeNameHud I added the following lines:
[removed]
This paints a white rectangle in the position that I want, but doesn't paint the bitmap. Any ideas?
Is there anything odd about dglDrawBitmapStretch in that you can't use transparent colours or the pics have to be under a certain size or whatever?
Thanks, TheGords
#12
You're violating the EULA by posting source code here. Move it to the Private Forum already.
07/19/2006 (6:54 am)
@Gordon:You're violating the EULA by posting source code here. Move it to the Private Forum already.
#13
07/19/2006 (7:15 am)
Sorry Stefan, I will start a new thread in an appropriate place.
#14
08/22/2006 (1:14 pm)
Got a link to the appropriate place? lol
#15
http://www.garagegames.com/mg/forums/result.thread.php?qt=47897
Gords
08/22/2006 (2:40 pm)
Yup, this thread got continued here:http://www.garagegames.com/mg/forums/result.thread.php?qt=47897
Gords
Torque Owner AllynMcelrath