Ejemplo n.º 1
0
        public void TriggerHeadThrow(Rigidbody rb)
        {
            rb.gameObject.transform.position = item.transform.position;
            List <Creature> creatures = Creature.list.Where(
                creature => creature != Player.currentCreature &&
                creature.state != Creature.State.Dead &&
                (creature.ragdoll.headPart.transform.position - item.transform.position).magnitude < throwTrackRange).ToList();

            if (creatures.Count > 0)
            {
                Creature target = creatures[new System.Random().Next(creatures.Count)];
                Debug.Log($"Throwing at {target.name}");
                rb.position = (target.ragdoll.headPart.transform.position - item.transform.position).normalized * 0.2f;
                rb.velocity = Vector3.zero;
                float modifier = 1;
                if (rb.mass < 1)
                {
                    modifier *= rb.mass * 2;
                }
                else
                {
                    modifier *= rb.mass;
                }
                rb.AddForce((target.ragdoll.headPart.transform.position - item.transform.position).normalized * modifier * throwTrackForce, ForceMode.Impulse);
                if (rb.gameObject.GetComponent <Item>().data.type != ItemPhysic.Type.Prop)
                {
                    CosmicSelfMerge.PointItemFlyRefAtTarget(rb.gameObject.GetComponent <Item>(), (target.ragdoll.headPart.transform.position - item.transform.position).normalized, 1);
                }
            }
            pewEffect.Spawn(item.transform).Play();
            rb.gameObject.GetComponent <Item>()?.Throw();
        }
Ejemplo n.º 2
0
 public void Update()
 {
     if (target)
     {
         item.rb.useGravity      = false;
         item.transform.position = Vector3.Lerp(item.transform.position, target.transform.TransformPoint(offset), Time.deltaTime * 10f);
         CosmicSelfMerge.PointItemFlyRefAtTarget(item, item.transform.position + target.forward, Time.deltaTime * 10f);
     }
 }