willemmulder Posted January 4, 2016 Share Posted January 4, 2016 While building an RTS, how would I go about creating a selection ring under a specific unit, like in Starcraft 2? What I mean is the green ring here: http://www.sc2mapster.com/media/attachments/22/523/Screen_Shot_2011-12-03_at_4.59.49_PM.png Right now I have a cylinder (a disc didn't seem to work, somehow) but it's solid. See http://www.babylonjs-playground.com/#1WZASW#34Any pointers? Quote Link to comment Share on other sites More sharing options...
Dal Posted January 7, 2016 Share Posted January 7, 2016 You can do it a number of ways... sometimes it's done on the GUI layer by drawing a 2D box around the object, sometimes its just a flat square mesh with a texture on it underneath, sometimes it's done with a decal on the terrain. If your surface is completely flat, the easiest way is probably to place some geometry under the mesh that can be moved around together with it... perhaps something like BABYLON.Mesh.CreateDisc("disc", 64, 30, scene);(http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements) If the terrain is bumpy though, you'll end up with it sticking through the terrain in places and need to move and rotate to stop it going through the terrain. In that case, it might be easier to use decals like http://doc.babylonjs.com/tutorials/17._Using_decals to pick the mesh under the object and draw a circle decal texture onto it. willemmulder 1 Quote Link to comment Share on other sites More sharing options...
iiceman Posted January 7, 2016 Share Posted January 7, 2016 I already posted this version in the other thread but for the sake of completeness: http://www.babylonjs-playground.com/#PSKRF#4 I also made another version that works on heightmap and rotates the texture instead of the mesh for the selection circle - http://www.babylonjs-playground.com/#PSKRF#5. But performance seems to be a bit of an issue here because it's using decals. I also think it might be a bit more complicated to keep them under the mesh when the mesh moves. But I am hoping that the new function jerome is working on will help to make that easier (for further reference: http://www.html5gamedevs.com/topic/19706-meshintersectsray-not-working-with-heightmap/). willemmulder and Raitch 2 Quote Link to comment Share on other sites More sharing options...
willemmulder Posted January 7, 2016 Author Share Posted January 7, 2016 Thanks Dal! I'm going to use the CreateDisc (in combination with a DynamicTexture that iiceman suggested).Perfect solution for what I'm using, because the terrain will be flat for now. I'll show it once I have something more substantial :-) Quote Link to comment Share on other sites More sharing options...
Raitch Posted November 23, 2016 Share Posted November 23, 2016 Sorry for potentially reviving this topic, but should you recreate and dispose decal upon movement or is it possible to move existing decal around to possibly run faster? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 23, 2016 Share Posted November 23, 2016 A decal is a mesh so you can move it Raitch 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.