Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How can create a shooting cut scene for a part of my adventure game ?

Discussion in 'Cinemachine' started by dubiduboni_unity, Apr 18, 2019.

  1. dubiduboni_unity

    dubiduboni_unity

    Joined:
    Feb 11, 2019
    Posts:
    116
    Something more realistic. It's not part of a shooter game it's part of adventure game point and click and a cut scene I want to do at some point in the game that show a close range of a npc changing animations from walk to shooting and then to show the bullets coming out in slow motion.

    I don't need a target or something I just want to make a cut scene like cinematic in games. Not really cinematic but the idea.

    First step I created a new Animator Controller. And added two states WALK and SHOOTING. A transition between them without exit time and duration 5.

    Added a bool parameter and called it Shooting added the parameter to the transition in the inspector and set it to false. The npc have the animator attached and now it's changing nice and smooth from walking to shooting animations.

    Now when it's in the shooting animation once the shooting animation start I want to show the bullets coming out in slow motion I prefer and to some random directions but in a small angle more or less to the forward.

    Screenshot of the animator and the npc inspector :



    Next screenshot show the transition settings in animator between the walk and shooting animations :



    Next what I did is adding a empty gameobject with the right position,rotation,scaling that will be child of the rifle. And attached to this empty gameobject a script name Shooting the script get a prefab Bullet :



    And the bullet prefab settings :



    This is the Shooting script :

    Code (csharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5.  
    6. public class Shooting : MonoBehaviour
    7. {
    8.    public GameObject projectile;
    9.    public Animator anim;
    10.  
    11.    private void Start()
    12.    {
    13.        anim.SetBool("Shooting", true);
    14.    }
    15.  
    16.    private void Update()
    17.    {
    18.        if (anim.GetBool("Shooting") == true)
    19.        {
    20.        GameObject bullet = Instantiate(projectile, transform.position, Quaternion.identity) as GameObject;
    21.        bullet.GetComponent<Rigidbody>().AddForce(transform.forward * 10, ForceMode.VelocityChange);
    22.        }
    23.    }
    24. }
    25.  
    I'm trying to check in the script if the Shooting parameter is true then start shooting. If the animation of the shooting start then shoot. But now when running the game it's never changing to the shooting animation. And it's leaving trail of bullets behind the player :



    And last since each bullet that was created each clone have a spot light I added to make a light on each bullet it's making the npc brighter and brighter :

     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    I don't see a camera-related question here. Maybe you can try posting this on a different forum, where you can get help with your animation issue?
     
    dubiduboni_unity likes this.