Unity Community

Register or Sign In:

+ Reply to Thread
Page 4 of 14 FirstFirst ... 2 3 4 5 6 ... LastLast
Results 61 to 80 of 262

  1. Location
    Alabama
    Posts
    934
    Wow. I really liked the feel of that latest demo. Just curious, when you shoot the gun, are raycasts used and do you just offset them by some random degree? I like how the bullet doesn't just go in a straight line.


  2. Location
    Barranquilla - Colombia
    Posts
    98
    Well, you use the duck law.

    A duck Swim, fly and run... but...

    a duck don't swim like a fish, don't fly like a eagle and don't run like a cheeta.

    is ok, I agree about learn everything about design of a Videogame, but for a Good, really, really good project you need the best people in your area.

    Twiik, can you put the tracer bullets in the last example? Sorry for bother you...again.


  3. Location
    Trondheim, Norway
    Posts
    788
    Wow. I really liked the feel of that latest demo. Just curious, when you shoot the gun, are raycasts used and do you just offset them by some random degree? I like how the bullet doesn't just go in a straight line.
    Yes, I use raycasts for the pistol, shotgun and machine gun, but I still use game objects for my bullets. I would never have come up with this on my own, but luckily I disocvered Spk's paintrain thread where he posted an example of doing it this way. This allows for having actual bullet speeds instead of instant hits like you get with raycasts and you can attach models, tracers, particles etc. to your bullet game objects. The "recoil" is just a random rotation which increases the longer you hold the trigger.

    In the demo bullets would sometimes pass through enemies or crates without registering a hit, but I've updated the bullet code locally after uploading the latest build and now I can have the bullets go at nearly infinite speeds without passing through objects.

    A thing I've been wanting to implement is ricochets and bullet penetration. I guess you can use the RayCastAll function for bullet penetration and probably all it takes to get decent looking ricochets is to write an extremely simple "physics"-engine which only calculates angles related to the impact point normal.


    Twiik, can you put the tracer bullets in the last example?
    The tracer bullets don't work with the example project because like I said they are just standard trail renderer components attached to my bullets which are game objects. In the example project there are no bullets, just ray casts and instantaneous impacts.

    I may upgrade the project later, but look at what Spk posted in his Paintrain thread to see what my bullet code is based on. My initial version was nearly a straight copy.

    To make tracers just make a simple weapon (take the rocket launcher from the first person shooter tutorial for instance) and replace the rockets with empty game objects with a trail renderer attached. Then copy the settings I showed on the last page and apply the texture I uploaded.

    but for a Good, really, really good project you need the best people in your area.
    I believe your duck law theory is flawed. There's no reason one man can't be extremely talented in all areas of game making. Some of my all time favorite games and mods are made by one man.

    The reason AAA games are made by big teams is because its just way to much work for one guy. But there's tons of examples of very impressive indie projects created by one or two guys. And the reason AAA games take so much time these days is mostly to blame on the great looking graphics we all expect. It takes ages to create the high poly models, to texture them, to program the shaders and the graphics engine.

    Compare the graphics of 1 enemy in Gears of War to 1 enemy in Doom. The enemy in doom is just 4 or 5 low res images whereas the enemy in GoW probably has 4-5 much higher res images just for the texture of his rifle. And yet Doom was a lot more fun then than GoW is now. And with a small amount of polish Doom would be even more fun now. And I know Unity and myself can't compete with the graphics of the latest games so state of the art graphics are what I'm focusing the least on, thus saving me a ton of time when making my game(s). That will be my policy: "I make fun, not graphics" =D

    Also if I get some experience with everything now then when I start a bigger project later on I can outsource for example the making of the weapons and I can tell whoever's on the job exactly what format I need the models in and how I want the animations.


  4. Posts
    246
    Yes, I use raycasts for the pistol, shotgun and machine gun, but I still use game objects for my bullets. I would never have come up with this on my own, but luckily I disocvered Spk's paintrain thread where he posted an example of doing it this way. This allows for having actual bullet speeds instead of instant hits like you get with raycasts and you can attach models, tracers, particles etc. to your bullet game objects. The "recoil" is just a random rotation which increases the longer you hold the trigger.

    In the demo bullets would sometimes pass through enemies or crates without registering a hit, but I've updated the bullet code locally after uploading the latest build and now I can have the bullets go at nearly infinite speeds without passing through objects.

    A thing I've been wanting to implement is ricochets and bullet penetration. I guess you can use the RayCastAll function for bullet penetration and probably all it takes to get decent looking ricochets is to write an extremely simple "physics"-engine which only calculates angles related to the impact point normal.
    Hello TwiiK, do you intend sharing this Raycast + Bullet method? it's very interesting.


  5. Location
    Trondheim, Norway
    Posts
    788
    Sure, here's my entire bullet code:

    using UnityEngine;
    using System.Collections;

    public class Bullet : MonoBehaviour {

    public float speed = 500.0f;
    public float life = 3;
    public GameObject impactEffect = null;
    public GameObject bulletHole;
    public int damage = 20;
    public float impactForce = 10;

    private Vector3 velocity;
    private Vector3 newPos;
    private Vector3 oldPos;
    private bool hasHit = false;

    void Start() {
    newPos = transform.position;
    oldPos = newPos;
    velocity = speed * transform.forward;

    // schedule for destruction if bullet never hits anything
    Destroy( gameObject, life );
    }

    void Update() {
    if( hasHit )
    return;

    // assume we move all the way
    newPos += velocity * Time.deltaTime;

    // Check if we hit anything on the way
    Vector3 direction = newPos - oldPos;
    float distance = direction.magnitude;

    if (distance > 0) {
    RaycastHit hit;

    if (Physics.Raycast(oldPos, direction, out hit, distance)) {
    // adjust new position
    newPos = hit.point;

    // notify hit
    hasHit = true;

    Quaternion rotation = Quaternion.FromToRotation(Vector3.up, hit.normal);
    Instantiate(impactEffect, hit.point, rotation);

    if (hit.rigidbody)
    hit.rigidbody.AddForce( transform.forward * impactForce, ForceMode.Impulse );

    // if we hit geometry we spawn a bullet hole
    if (hit.transform.tag == "Geometry") {
    GameObject instantiatedBulletHole = Instantiate(bulletHole, hit.point, rotation) as GameObject;
    }

    hit.transform.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver);

    Destroy (gameObject, 1);
    }
    }

    oldPos = transform.position;
    transform.position = newPos;
    }
    }
    If you have looked at Spk's bullet code in his Paintrain thread you will notice mine is heavily based on his. I've basically just removed the parts I didn't understand and replaced a few other parts.

    His is surely more advanced and probably better if you can understand it, but a major difference is that I use Physics.Raycast instead of Physics.RaycastAll which he used in the original script.

    I want to be able to use RaycastAll eventually because I'm guessing that will allow me to add proper bullet penetration fairly easily seeing as it returns all hits instead of just the first. So with some clever modification of ranges I can have different penetration depending on the material hit, at least that's the theory.


  6. Posts
    246
    Thank you! I'll see if i understand it a little better an will try to convert to JS. :wink:


  7. Location
    Trondheim, Norway
    Posts
    788
    Here it is in Javascript:

    var speed = 500.0;
    var life = 3;
    impactEffect : GameObject;
    bulletHole : GameObject;
    var damage = 20;
    var impactForce = 10;

    private velocity : Vector3;
    private newPos : Vector3;
    private oldPos : Vector3;
    private var hasHit = false;

    function Start() {
    newPos = transform.position;
    oldPos = newPos;
    velocity = speed * transform.forward;

    // schedule for destruction if bullet never hits anything
    Destroy( gameObject, life );
    }

    function Update() {
    if( hasHit )
    return;

    // assume we move all the way
    newPos += velocity * Time.deltaTime;

    // Check if we hit anything on the way
    var direction = newPos - oldPos;
    var distance = direction.magnitude;

    if (distance > 0) {
    var hit : RaycastHit;

    if (Physics.Raycast(oldPos, direction, hit, distance)) {
    // adjust new position
    newPos = hit.point;

    // notify hit
    hasHit = true;

    var rotation = Quaternion.FromToRotation(Vector3.up, hit.normal);
    Instantiate(impactEffect, hit.point, rotation);

    if (hit.rigidbody)
    hit.rigidbody.AddForce( transform.forward * impactForce, ForceMode.Impulse );

    // if we hit geometry we spawn a bullet hole
    if (hit.transform.tag == "Geometry")
    Instantiate(bulletHole, hit.point, rotation);

    hit.transform.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver);

    Destroy (gameObject, 1);
    }
    }

    oldPos = transform.position;
    transform.position = newPos;
    }
    I can't confirm that it compiles since I did it at work where I don't have Unity, but if it doesn't there's probably only 1 or 2 small errors in there. "Converting" such a script to JS is mostly just replacing all the type definitions with "var" and replacing "void" with "function".


  8. Location
    Connecticut
    Posts
    290
    thats really neat, and I probably sunk about 30 minutes into playing it (got to wave 5). My only advice would be to start on the new enemy types quickly, so that you can start balancing waves more instead of just increasing the amount of enemies.

    I have actually been working on a similar project ( FPS wave defense game), and I have to say that this is very impressive.


  9. Posts
    37
    wow twiik i missed this,hehehe what an excellent game,fun to play even as it stands
    cant beat level7 tho,spent hours on it lol.
    CPU: Intel(R)Core(TM)2 Quad CPU Q6600 @ 2.40GHz (4CPUs),~2.4GHz
    Gfx: Nvidia GeForce 9600GT 512
    Memory: 3070MB RAM
    Mobo: MSI MS-7379VP microATX
    Windows VISTA Home premium


  10. Location
    Trondheim, Norway
    Posts
    788
    Thanks for the comments.

    Most of what you see now are placeholders, obviously, and new and more enemy types will come eventually.

    I've actually changed it to a FPS now, but I won't upload a new version until I have something to show.

    Things I'm working on at the moment:
    - New and cooler effects
    - More effects (different impact effects depending on surface and material)
    - Some bug fixes
    - Variation to everything (multiple muzzle flashes, multiple bullet holes etc.)
    - And a bunch of experiments and tests for fun

    Up to this point I've loved everything about Unity, but recently I've been playing with the particle system and to be honest I'm finding it quite lacking. I'm used to the event based and rule based particle systems you find for 3ds max like Particle Flow and Thinking Particles.

    Of course I'm not expecting anything like that, but one thing that's really holding me back is per particle spin/rotation. I guess you could create animated textures of spinning particles, but that's not a very efficient way of doing it and the results won't be as good.

    A simple node based particle system similar to Particle Flow for 3ds max would really rock.


  11. Posts
    246
    Quote Originally Posted by TwiiK
    Here it is in Javascript:

    var speed = 500.0;
    var life = 3;
    impactEffect : GameObject;
    bulletHole : GameObject;
    var damage = 20;
    var impactForce = 10;

    private velocity : Vector3;
    private newPos : Vector3;
    private oldPos : Vector3;
    private var hasHit = false;

    function Start() {
    newPos = transform.position;
    oldPos = newPos;
    velocity = speed * transform.forward;

    // schedule for destruction if bullet never hits anything
    Destroy( gameObject, life );
    }

    function Update() {
    if( hasHit )
    return;

    // assume we move all the way
    newPos += velocity * Time.deltaTime;

    // Check if we hit anything on the way
    var direction = newPos - oldPos;
    var distance = direction.magnitude;

    if (distance > 0) {
    var hit : RaycastHit;

    if (Physics.Raycast(oldPos, direction, hit, distance)) {
    // adjust new position
    newPos = hit.point;

    // notify hit
    hasHit = true;

    var rotation = Quaternion.FromToRotation(Vector3.up, hit.normal);
    Instantiate(impactEffect, hit.point, rotation);

    if (hit.rigidbody)
    hit.rigidbody.AddForce( transform.forward * impactForce, ForceMode.Impulse );

    // if we hit geometry we spawn a bullet hole
    if (hit.transform.tag == "Geometry")
    Instantiate(bulletHole, hit.point, rotation);

    hit.transform.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver);

    Destroy (gameObject, 1);
    }
    }

    oldPos = transform.position;
    transform.position = newPos;
    }
    I can't confirm that it compiles since I did it at work where I don't have Unity, but if it doesn't there's probably only 1 or 2 small errors in there. "Converting" such a script to JS is mostly just replacing all the type definitions with "var" and replacing "void" with "function".
    Oh, thank you! My JS version was a little different... maybe that's why it wasn't working so well. So much to learn, lol.


  12. Location
    Philippines
    Posts
    782
    Twiik, how did you code your bullets so they aim exactly at the crosshair?

    I have a problem with a 3rd person shooter I am making:
    http://anomalousunderdog.webs.com/unity/TPSTest.html

    In my test I simply do a ScreenPointToRay raycast using the middle of the screen as coordinates, however when I aim at the sky, of course, the raycast hits nothing so my aim object does not update.

    I tried fixing it by parenting my aim object to the camera so it moves up and down even when the player is aiming at the sky, but its not accurate, the movement doesn't follow the crosshair properly.

    You can test it in the link I gave. A sphere represents the aim object for debug. When you aim at the ground and the cube it works as expected, but when you aim at the sky, the sphere aim object moves too sensitively.

    How did you fix this in your game?


  13. Posts
    10
    hey mate looks awesome, but could you upload a windows standalone version ?


  14. Posts
    4
    Hey.
    Great project! helped me understand Unity a lot more. Is there a chance you could implement your bullet code in the Third Person Test project?

    regards


  15. Location
    Trondheim, Norway
    Posts
    788
    Quote Originally Posted by anomalous_underdog
    Twiik, how did you code your bullets so they aim exactly at the crosshair?
    I have a raycast going from the camera to the center of the screen and I position a game object at the hit point for the guns to look at. This works exactly like in your example in that it doesn't work if you aim at the sky.

    For that case I take the last known position of the game object (probably the last wall you aimed at before you aimed at the sky) take the distance from the camera to the "target" game object for that last position and just have the game object set at that distance, in the center of the screen, until you look at the ground again.

    It's not perfect because it looks slightly weird when you shoot going from the ground to the sky or vice versa. And because I'm using raycasts it can get very messed up if something comes right in front of the raycast.

    I played and looked at games like Gears of War and Ghost Recon Advanced Warfighter when I was doing the aiming, but I have no idea how they've done the aiming because it doesn't look like it's done with raycasts like in my example.

    In the first person example I just shoot from the center of the screen because there's no projectiles or tracers so there's no need for raycasts.

    I have changed my project to a first person shooter locally now, but I'm still struggling with the aiming. You would think that proper first/third person aiming was something described in detail on any game coding website, but I've been unable to find any help or tips using google.

    Quote Originally Posted by MikeDom
    hey mate looks awesome, but could you upload a windows standalone version ?
    The next update I will see how a standalone compares to the webversion and upload what I think works best.

    Quote Originally Posted by stippi
    Hey.
    Great project! helped me understand Unity a lot more. Is there a chance you could implement your bullet code in the Third Person Test project?
    Do you mean the first person example project I posted earlier? I'll see if I can do it when I have some spare time.


  16. Posts
    10
    why not upload both ? This way everybody can test them out and tell you which one works faster on diferent rigs. :wink:


  17. Posts
    37
    Twiik,I got my kids into the game and theyre hooked :lol: they love it even in its "unfinished" state it has that originality in look and feel,I reckon its a winner as it stands and to add lots of detail and textures,proper modelled monsters etc,might take that uniqueness away.
    CPU: Intel(R)Core(TM)2 Quad CPU Q6600 @ 2.40GHz (4CPUs),~2.4GHz
    Gfx: Nvidia GeForce 9600GT 512
    Memory: 3070MB RAM
    Mobo: MSI MS-7379VP microATX
    Windows VISTA Home premium


  18. Location
    Trondheim, Norway
    Posts
    788
    Mike, we'll see.

    That's awesome, jojimbo. This was never meant to become a finished game, but just a project for experimenting and learning so a lot of things will probably change.

    For instance the next update will be first person instead of third person and it may feature some blood so it may not be so kiddy friendly.

    But whatever game I eventually end up making the graphics will be somewhat like what I have now - with detailed effects that stand out from the simple geometry and enemies. I really like that look.


  19. Posts
    37
    hehe yup,the look of shock/horror as they turn round to see all those things chasing was golden.
    CPU: Intel(R)Core(TM)2 Quad CPU Q6600 @ 2.40GHz (4CPUs),~2.4GHz
    Gfx: Nvidia GeForce 9600GT 512
    Memory: 3070MB RAM
    Mobo: MSI MS-7379VP microATX
    Windows VISTA Home premium


  20. Location
    Philippines
    Posts
    37
    Wondering if you will post the zip file of the whole unity project as it is in the tutorial section. :roll: lol :lol:
    But it's fun to play! Awesome idea.
    I'll be learning the spawn of pick ups when player dies... Can't get it yet.


 
+ Reply to Thread
Page 4 of 14 FirstFirst ... 2 3 4 5 6 ... LastLast