Unity Community

Register or Sign In:

+ Reply to Thread
Page 2 of 5 FirstFirst 1 2 3 4 ... LastLast
Results 21 to 40 of 96

  1. Location
    Chicago
    Posts
    55

    contribution/question

    Hi!

    Thanks again for this great boost Martin! I've been trying to add combat to this mod. It's not much but I'm trying to create a function that "kills" a unit when he's hit by an object with the tag "missile" that comes out of the Turret. logically I tried to Destroy the game object that got hit. Unity doesn't like that. I get an error message. (Null Reference) For now I have just "moved" the tanks hit. I get some type of weird era too. What I want to do is remove the game object once he takes enough hits. Only problem is for now each unit is using the same script.

    So the question: How can I remove the hit object without causing a Null Error.

    Here's the code:

    Code:  
    1. function OnCollisionEnter (collision : Collision)
    2. {
    3.  
    4. if  ( collision.gameObject.tag == "missle")
    5.    
    6.       { 
    7.     Destroy (gameObject);
    8.     print("Hit by a missle");
    9.     transform.Translate (Vector3, x, y, z) ;
    10. //var attackedunit = gameObject.GetComponent(Transform);
    11.  
    12.     }   
    13. }


  2. Location
    chicago, IL, USA
    Posts
    373
    hey, I'm working on a game involving hits/destroy, etc, my code goes something like this:


    function OnTriggerEnter (other : Collider)
    {
    if (other.gameObject.CompareTag ("Missile"))
    {
    Destroy(gameObject);
    }
    }


    That's about as simple as it can get, works just fine for me! This code would be placed in the tank's script somewhere, thus the " if other = "missile" ("other" is whatever hit us), and then "destroy game object" (destroy whatever object this script is on).

    Hope that helps!


  3. Location
    chicago, IL, USA
    Posts
    373
    addition: I'm still very noobtastic with programming, but I would bet your error was called by FIRST calling the "Destroy" command, THEN calling the other stuff.

    Can't call commands on something if it has already been destroyed! :P

    (could be completely wrong though...haha)


  4. Posts
    7
    Don't bother with "fog of war" - as in black areas on your map. You don't need it. Using darkness to represent fog of war is an artifact that appears only with Civilization - all the RTS's inherited that idea from that game, but it didn't exist as a visual concept prior to that.

    True fog of war is just the idea that you can't see the position of enemy units. But in a modern battle you should ALWAYS see the map. Why? Because you are a general: you have a map of the battlefield. You're not exploring, you're fighting a battle.

    Just make a map, and if the unit is not visible, leave it undrawn. That's all the fog of war you need.

    World in Conflict, for example, works fine using this very system.


  5. Location
    chicago, IL, USA
    Posts
    373
    what? no fog of war? Obviously, it is just something made up arbitrarily long ago by the Ancient Ones of RTS games, but it does serve good purpose! At least to my mind, having the fog tells me that I cannot "see" units in that area- otherwise I'm liable to overlook huge areas of terrain, because they look exactly like the rest, and then suddenly units start popping into existance along that line? Not cool, not realistic, not fun. (in my opinion).

    This project needs a revival! I think a LOT of people would be interested, but sadly no real progress


  6. Location
    Hamburg, Germany
    Posts
    1,350
    Quote Originally Posted by yahodahan
    This project needs a revival! I think a LOT of people would be interested, but sadly no real progress
    Feel free to add your improvements back into the project.
    Latest release: RC Mini Racers.


  7. Location
    chicago, IL, USA
    Posts
    373
    haha, I know, I know- I'm all problems and no solutions!

    soon as I have time (tonight?) I have several goodies to add!


  8. Posts
    245
    hey guys, i like ur game, and it insipired me to make my own rts style game. i was having trouble making a group select and move with mouse script, i know the functions are in the vehicle script, but i could not seam to seperate it from the other vechile stuff that i dont need can some one please help me to get the parts i want or tell me how to make a new select and move with mouse scrpt similar to this.

    thanks again for sharing ur project its great help to teaching noobs like me.

    any help would be great.
    thanks


  9. Location
    Philippines
    Posts
    782
    Hi all, I see you guys are debating the need for fog-of-war. If ever you do want to have it, here's an implementation I made.

    It does the dissipating and redarkening of the fog-of-war, and showing/hiding of enemy units that are in/out of the fog.

    Web player:
    http://anomalousunderdog.webs.com/un...OfWarTest.html

    Source code found here (1.3 MB):
    http://dl.dropbox.com/u/25260770/Fog...ogOfWarTest.7z

    I've sent a PM to Martin just in case.
    Last edited by anomalous_underdog; 10-31-2011 at 03:23 PM.


  10. Location
    Köln (Cologne), Germany
    Posts
    13
    at underdog:
    This fog of war is really nice...

    at Martin:
    Did you implement Pathfinding in your project already? If not, take a look at Aaron Granbergs A* pathfinding 2.5. It works great. I tried it with my own RTS-project, and the only thing I had to do, was to write a few lines of code.
    It shouldnt be difficult to implement it in your project either.

    My next step in my own Project will be to avoid collision of multiple moving units. I thought about crosschecking the paths of the units, but this would need an additional variable at each point of the path, which contains the estimated time the unit will be at this point. Then I can compare all paths and for example order a unit to stop for a while or find a way around... I am not happy with that... I think, I have to rethink the whole thing...
    But maybe someone has a better idea?


  11. Location
    Zürich, Switzerland
    Posts
    25,088
    You better don't do individual paths right from the start.

    Create dynamic flocks (force areas, softbody blobs or whatever you want to call them) and search a path for them and then make the ai resort local movement constraints between each other.

    If you have an AIGameDev premium subscription you will find a few interesting videos / classes on how the devs of Demigod / Supreme Commander approach it as well as a Blizzard way of doing it related one.


  12. Posts
    209
    sorry to necro this thread but I had a question about the healthbar prefab.

    The healthbar prefab has two elements "health" and "background" ... ok well background exists but I cant find the Health peice anywhere. I think it is supposed to be embeded into the prefab but it is not in v 1.1

    This is causing alot of problems trying to port this into my environment. I tried to make my own health element but i keep getting the error "Prefab "GameObject's can not be made active"

    any advice?


  13. Posts
    9
    Sorry, for yet another Necro(I'm sad this topic died at all)

    I am also curious about the healthbar prefab and code, I have attempted to replicate it... and modify it, however it gives me a host of errors...

    I am interested in continuing development in the RTS area for Unity, I am not interested in purchasing a $200 prefab from some group, that is not really built around my needs.

    I suggest actually reviving or rebuilding a thread for this type of project. This genre of game is still popular and I am extremely surprised to find a very, very large lack of projects or documentation on this type of project.

    If, however, the revived conversation and development already exists, I'd love to be linked to it.

    Thanks,
    Craze.


  14. Location
    Belgium
    Posts
    65
    Hi,

    Just to thank Martin for sharing this project, I needed a group select system and I adapted it to my needs, great work and many thanks

    I used a different approach for knowing wich unit is selected, when the camera rotates sometime with your code units where not selected on the fringe of the 2D rectangle, but were inside it, I finaly used a "point-in-polygon" function based on the 4 raycast casted by the 4 corners of the 2D rectangle

    (if that interests someone : http://forum.unity3d.com/threads/690...ection-problem )


  15. Posts
    95
    @ Martin Shultz - Great work. I downloaded it yesterday to play with it. Although it's just the two tanks it was quite entertaining. I play Halo Wars so I know how far this can go. Where is the project now? I would love to see how far it has come. Thanks again. I was more looking to do an RTS on the iPhone/iPad.. something about having "total war" in the palm of your hands. Cheers mate!


  16. Posts
    1
    Anyone know how to convert the code so itll work on android and iphone? would really appreciate it


  17. Posts
    19
    Truly... awe-inspiring. Thanks for the project.. it'd be nice to improve it. Anyone started toying with it? BTW, the conversion to the newer version of Unity is a piece of cake. ;-)


  18. Location
    United States
    Posts
    395
    Yeah, this project is really what led to mine. You can still see elements of this in mine. Amazing job!
    Rated E for Exceptional

    RTS Pro Pack
    http://www.gameprefabs.com/products/show/93
    Tower Defense Pack
    http://www.youtube.com/watch?v=8Y_zckJknJk


  19. Location
    Michigan
    Posts
    13
    Is this community project dead? I am new to Unity. I have been a C# programmer since 2005 and before that C and C++ and have been in the IT field for over 25 years. Yes, I am an old man.

    Bill


  20. Location
    Zürich, Switzerland
    Posts
    25,088
    Dead is relative.
    Its there but the community always only took part to a very little degree, but I'm sure with a few pushing in there will be much more movement again