K_Tec
1
Hello,
i want that if my rigidbody collide with some tagged colliders than it spawn the particle system for the tag-
tag wood-wood particles this is my code:
using UnityEngine;
using System.Collections;
public class ImpactScanner : MonoBehaviour {
public GameObject MetalParticles;
public GameObject WoodParticles;
public GameObject DirtParticles;
public GameObject BodyImpact;
public float DestroyTime;
void Start () {
Destroy(gameObject, DestroyTime);
}
void OnCollisionEnter(Collision collision) {
if (other.CompareTag("Metal")) {
MetalParticles instantiatedProjectile = Instantiate(projectile,transform.position,transform.roation) as GameObject;
}
if (other.CompareTag("Wood")) {
WoodParticles instantiatedProjectile = Instantiate(projectile,transform.position,transform.roation) as GameObject;
}
if (other.CompareTag("Dirt")) {
DirtParticles instantiatedProjectile = Instantiate(projectile,transform.position,transform.roation) as GameObject;
}
if (other.CompareTag("Player")) {
BodyImpact instantiatedProjectile = Instantiate(projectile,transform.position,transform.roation) as GameObject;
}
}
}
but i always get this error 
Assets/FPS REALISM PRO KIT/KerboGames/Scripts/Projectile/ImpactScanner.cs(30,33): error CS0118: ImpactScanner.WoodParticles' is a field’ but a `type’ was expected
and this wich every particles
Have a nice Day
Regards
Like the error says, WoodParticles is not a type, but a field. You will get this error with all of your code lines with Instantiate in the ImpactScanner.cs script.
You have to leave the instantiatedProjectile out of the function call:
WoodParticles = Instantiate(projectile,transform.position,transform.roation) as GameObject;
And use else if as there is no need to check all of the objects if one is already found.