Jump to content

How to create a selection ring like in Starcraft 2?


Recommended Posts

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#34

Any pointers?

Link to comment
Share on other sites

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);


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.

Link to comment
Share on other sites

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/).

Link to comment
Share on other sites

  • 10 months later...

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...