|
Post by projectonegames on Aug 21, 2016 12:45:43 GMT
This product is really fantastic. I am building a cool adventure with it and it is a lot of fun to work with. In one part, I have an array of archers standing above the player and companion. They are flooding the sky with flaming arrows. These arrows rain down on them and they must avoid them or be damaged. The arrows are created by a script. I have been unable to get them to connect to the damage within your product. This script (below) is where we trigger the damage. Any advice? (I will post a demo of what it looks like when I get it to work. )
using UnityEngine;
using System.Collections;
using Invector.CharacterController;
using Invector;
namespace firearrows
{
public class HitMe : MonoBehaviour
{
public void BlowMeUp ()
{
//Damage (gameObject);
}
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
}
}
}
|
|
|
Post by jgiroux on Aug 21, 2016 15:37:50 GMT
You can always add a collider trigger to your arrow object prefab and try using this
Trigger particle/Damage on hit
then just add the above script to your arrow prefab as well.
allows you to damage player and create a VFX upon hit as well.
if you truly need something to work in your own script, I can write something up for you... should it trigger at
HitMe : MonoBehaviour?
or
public void BlowMeUp ()
?
|
|
|
Post by projectonegames on Aug 22, 2016 15:03:16 GMT
THAT WORKS PERFECTLY!!! I can share what I have, It is essentially a weapon which fires a flaming arrow. It has prediction logic in it as well. Also, it is using another unity asset package. Fire Arrows - Unity Asset Package
|
|
|
Post by jgiroux on Aug 22, 2016 22:53:24 GMT
Great to hear! as to whether or not you would like to share your work is entirely up to you It sounds really neat I must say. but again, your choice. we all just like to help each other out around here.
|
|
|
Post by projectonegames on Aug 23, 2016 3:56:07 GMT
sharing is caring. And I care. Will post an android APK if anyone wants to see it. It is over 500 meg right now, multiple scenes and about 60 characters. It is rough, but 50 percent there.
I have some suggestions for your outstanding product, that will possibly help others. There is only a small set of people who truly understand us and what we know and how we will change the world. We need to stick together. peace out
|
|
|
Post by Rameet on Aug 23, 2016 13:26:03 GMT
[quote author=" projectonegames" source="/post/238/thread" timestamp="1471924567" There is only a small set of people who truly understand us and what we know and how we will change the world. We need to stick together. peace out[/quote] Thanks for that awesome line. This will be my WhatsApp status for long time. :D
|
|
|
Post by Invector on Aug 23, 2016 17:27:45 GMT
sharing is caring. And I care. Will post an android APK if anyone wants to see it. It is over 500 meg right now, multiple scenes and about 60 characters. It is rough, but 50 percent there. I have some suggestions for your outstanding product, that will possibly help others. There is only a small set of people who truly understand us and what we know and how we will change the world. We need to stick together. peace out We would love to see your project projectonegames, please feel free to post on our W.I.P section whenever you feel it's ready to show
|
|
|
Post by projectonegames on Sept 30, 2016 21:46:34 GMT
Do you know if I referring to the enemy health the correct way? I want to damage the enemy with this flaming arrow. But when I use the script for "Enemy" I get this: NullReferenceException: Object reference not set to an instance of an object DamageCollider.OnTriggerEnter (UnityEngine.Collider other) (at Assets/DamageCollider.cs:26) And the damage does not register.
I was looking for something to reuse, but I am coming up short. Do you have any ideas, maybe?
using UnityEngine; using System.Collections; using Invector.CharacterController; using Invector;
public class DamageCollider : MonoBehaviour {
public GameObject ParticlePrefab; // particle prefab we want to create public Vector3 ParticleOffset = new Vector3(-1f, 1f, 0f); // offset for particle, leave as is for it to show at players head level private bool DoOnce = false; // a bool to keep trigger from repeating more than once public bool CauseDamage = true; // check true if we want damage applied as well/ leave false if no damage is to be taken public int DamageAmount; // If above true, how much damage is taken. void OnTriggerEnter(Collider other) { // check if we are our player, // if (other.gameObject.tag == "Enemy" || other.gameObject.tag == "Player" || other.gameObject.tag == "CompanionAI") if (other.gameObject.tag == "Enemy") { if (DoOnce == false) // hasnt triggered yet { PlayParticleAtLocation(); // Play Particle //if (CauseDamage == true)// if we want damage to occur { other.GetComponent<vThirdPersonController>().currentHealth = other.GetComponent<vThirdPersonController>().currentHealth + -DamageAmount; // adjust players health for damage } DoOnce = true; // lock trigger to not happen again till exit collider } }
if (other.gameObject.tag == "Enemy") { if (DoOnce == false) // hasnt triggered yet { PlayParticleAtLocation(); // Play Particle // if (CauseDamage == true)// if we want damage to occur { other.GetComponent<vThirdPersonController>().currentHealth = other.GetComponent<vThirdPersonController>().currentHealth + -DamageAmount; // adjust players health for damage } DoOnce = true; // lock trigger to not happen again till exit collider } } }
void OnTriggerExit(Collider other) { // check if we are our player if (other.gameObject.tag == "Enemy") { if (DoOnce == true) { DoOnce = false; // reset bool to false so we can retrigger event again } } }
public void PlayParticleAtLocation() // custom function for instantiating prefab { Instantiate(ParticlePrefab, transform.position + ParticleOffset, Quaternion.identity); // Add other code here, if you want to add to it, sound perhaps, etc... } }
|
|
|
Post by jgiroux on Oct 1, 2016 2:16:45 GMT
instead of
other.gameObject.tag
try replacing all lines with
other.transform.tag
my guess is whatever is triggering the collider doesn't have the TAG set, maybe like the leg collider or something/
using transform should work, as it will grab the top most layer of the game object I believe.
let me know if that worked for you/
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Dec 4, 2016 3:30:24 GMT
Did it work? I'm curious, and I'm sure the flaming arrows look cool
|
|