Showing posts with label sniper shooter unity 3d. Show all posts
Showing posts with label sniper shooter unity 3d. Show all posts

Monday, 8 December 2014

Applying force in opposite direction of collision:

After banging my head to each and every script available and possible resource. I came up with the following code  It might help other people with the problem like kicking a football or 8-ball game or etc. The code is for 2D games in Unity, So here it is


public float explosionStrength = 10.0f;
void OnCollisionEnter2D(Collision2D collision) {
Collider2D collider = collision.collider;
 //Debug.Log("Collision with ball "+collider.name);
 if(collider.name == "FootBall")
 { GameObject target_=GameObject.Find("FootBall");
    Debug.Log("Velocity is "+target_.rigidbody2D.velocity.normalized );
    Vector2 forceVec = -target_.rigidbody2D.velocity.normalized * explosionStrength;                  target_.rigidbody2D.AddForce (forceVec, ForceMode2D.Impulse);
    Debug.Log("Collision with ball");
 }

 }

Tuesday, 17 June 2014

Sniper Shooting prototype (Part 1)

Hi,

First of all what we need is a Sniper gun model (.fbx format) with the animation like


  • idle
  • walk
  • reload
So as I know that most of the game devs are not in to the 3D asset development so I am going to share the model of gun in this post. We will use the First person camera view with model (animations are included in the unity package).

Please download the package, drag the gun into your scene and see how the animations works. The motion which makes the sniper gun move little bit in and out of the axis because of wind pressure is part of idle animation so, it will help in making game little more interesting. (I have not made this model so we must thanks the random guy over who has shared it over the internet)

You can download from here