void OnControllerColliderHit(ControllerColliderHit hit)
    {
        collisionPoint = hit.point;



        // PUSH NON KINEMATIC RIGIDBODYS



        Rigidbody rb = hit.transform.GetComponent <Rigidbody>();


        float pushPower = 2.0f;


        // no rigidbody
        if (rb == null || rb.isKinematic)
        {
            return;
        }
        // We dont want to push objects below us
        if (hit.moveDirection.y < -0.3)
        {
            return;
        }
        // Calculate push direction from move direction,
        // we only push objects to the sides never up and down
        Vector3 pushDir = new Vector3(hit.moveDirection.x, 0, hit.moveDirection.z);

        // If you know how fast your character is trying to move,
        // then you can also multiply the push velocity by that.
        // Apply the push


        // if it is a bolt entity
        if (rb.GetComponent <BoltEntity>() != null)
        {
            if (BoltNetwork.IsServer)
            {
                rb.velocity = pushDir * pushPower;
            }
            else
            {
                var objMoved = ObjectMoved.Create(Bolt.GlobalTargets.OnlyServer);

                objMoved.Push     = true;
                objMoved.Entity   = rb.GetComponent <BoltEntity>();
                objMoved.Velocity = pushDir * pushPower;


                objMoved.Send();
            }
        }
        else
        {
            rb.velocity = pushDir * pushPower;
        }
    }
Example #2
0
    void SendDropEvent(BoltEntity ent, Vector3 velocity)
    {
        var objMoved = ObjectMoved.Create(Bolt.GlobalTargets.OnlyServer);

        objMoved.Hold = false;
        objMoved.Push = false;

        objMoved.Velocity = velocity;
        objMoved.Entity   = ent;

        objMoved.Send();
    }
Example #3
0
    // Events and their Overloads


    // Hold
    void SendHoldEvent(BoltEntity ent, Vector3 position, Quaternion rotation)
    {
        var objMoved = ObjectMoved.Create(Bolt.GlobalTargets.OnlyServer);

        objMoved.Hold = true;
        objMoved.Push = false;

        objMoved.Entity   = ent;
        objMoved.Position = position;
        objMoved.Rotation = rotation;

        objMoved.Send();
    }