Hi, i've tried to integrate puppetmaster with behaviour tree and UFPS, which has been working great so far, but i want to register an impact from puppetmaster when i hit a target with my projectile from "Shootable Weapon". I tried using physcial projectiles, but the speed of the projectiles ignore the impact, sadly.
I hope it's ok that i post the puppetmaster code, which is a raycast that applies force and "unpin" which makes the character/victim flinched and more wobbly from the impacts which will eventually make the character fall over. I've spent the whole day trying to integrate it myself, but can't do it, i'm very inexperienced with coding.
Code:
As of now this code does all that by clicking on a "puppet character", but i want to apply the same functions when my projectile hits the enemy.
Hope it's ok i ask this here
I hope it's ok that i post the puppetmaster code, which is a raycast that applies force and "unpin" which makes the character/victim flinched and more wobbly from the impacts which will eventually make the character fall over. I've spent the whole day trying to integrate it myself, but can't do it, i'm very inexperienced with coding.
Code:
- using UnityEngine;
- using System.Collections;
- using RootMotion.Dynamics;
- namespace RootMotion.Demos {
- public class RaycastShooter : MonoBehaviour {
- public LayerMask layers;
- public float unpin = 10f;
- public float force = 10f;
- // Update is called once per frame
- void Update () {
- if (Input.GetMouseButtonDown(0)) {
- Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
- // Raycast to find a ragdoll collider
- RaycastHit hit = new RaycastHit();
- if (Physics.Raycast(ray, out hit, 100f, layers)) {
- var broadcaster = hit.collider.attachedRigidbody.GetComponent<MuscleCollisionBroadcaster>();
- if (broadcaster != null) {
- broadcaster.Hit(unpin, ray.direction * force, hit.point);
- }
- }
- }
- }
- }
- }
As of now this code does all that by clicking on a "puppet character", but i want to apply the same functions when my projectile hits the enemy.
Hope it's ok i ask this here