- Home /
Simple RTS components.
I am trying to make a bare-bones-ish RTS style game, in which each player uses several boats to kill the other players' boats. I broke down what I need to complete this project, and want to see if any of these components have already been made.
- A top-down camera that can scroll when the mouse is moved to the edge of the screen.
- An RTS-style unit selection rectangle, so that you can select your boats and move them with a point-click.
- A battle system so that when a ship gets close enough to another ship, they kill each other.
- a battle system so that you can target an enemy boat with your boat.
- multiplayer?
It would be awesome if any of these were already in existence so that I don't have to try to make them myself. I would probably end up with cluttered monstrosities of code.
In the Unity Forums, there is a nice tank C&C community project. You could try and integrate some of that (I think it was in the Collaboration section.)
Answer by Scribe · Mar 27, 2011 at 11:31 AM
var CamSpeed = 1.00; var GUIsize = 25;
function Update () { var recdown = Rect (0, 0, Screen.width, GUIsize); var recup = Rect (0, Screen.height-GUIsize, Screen.width, GUIsize); var recleft = Rect (0, 0, GUIsize, Screen.height); var recright = Rect (Screen.width-GUIsize, 0, GUIsize, Screen.height);
if (recdown.Contains(Input.mousePosition))
transform.Translate(0, 0, -CamSpeed, Space.World);
if (recup.Contains(Input.mousePosition))
transform.Translate(0, 0, CamSpeed, Space.World);
if (recleft.Contains(Input.mousePosition))
transform.Translate(-CamSpeed, 0, 0, Space.World);
if (recright.Contains(Input.mousePosition))
transform.Translate(CamSpeed, 0, 0, Space.World);
}
when I was doing an RTS type game before I made this script for my camera so maybe it will help you.
It creates a non-visible rectangle on the side of the screen with an inset of 25 (var called GUIsize) when the mouse enters these areas it moves the camera in world coordinates (I made it world coordinates as my camera was angled at about 45 degrees like the total war games if you've ever played them)
You can change the cam speed to alter the speed of the cameras movement
Hope it helps you
Scribe
just thought id add that moving to the corners of the screen moves the camera diagonally