|
Post by Legion on Oct 7, 2017 0:11:36 GMT
We've modified the "vShooterWeapon" script to spawn bullet shells as prefabs instead of legacy particles, the prefab has collider, rigidbody and the following simple script, which is supposed to add a boost to the bullet shell: using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AddForce : MonoBehaviour {
public float X;
public float Y;
public float Z;
public Rigidbody ShellRB;
void Awake()
{
ShellRB = GetComponent<Rigidbody>();
}
void Start()
{
ShellRB.AddRelativeForce(X, Y, Z, ForceMode.Impulse);
}
void OnCollisionEnter(Collision collision)
{
this.enabled = false;
}
} The prefab, on its own, works perfectly, but once instanced, the force does not apply and the bullet shells fall down, as can be seen in the video: Any suggestions? There are people here with more idea than us
|
|
rich
Junior vMember
Posts: 38
|
Post by rich on Oct 9, 2017 9:01:48 GMT
Out of interest, are you using custom animations for that character?
|
|
|
Post by Invector on Oct 9, 2017 11:22:43 GMT
If the prefab is working fine on it's own then it's probably the shell collider hiting the player's collider, just make sure they don't collide using different layer.
|
|
|
Post by Legion on Oct 9, 2017 14:50:19 GMT
We tried to put the shells in the "Ignore Raycast" layer, but they passed through the ground, the problem was the floor of the demo, we suppose the mesh collider of this, with a different floor works well in that layer. Yeah, from this publisher.
|
|
|
Post by Legion on Oct 9, 2017 17:55:14 GMT
Btw, if someone want to spawn gameobjects instead of particles, these are the changes that we have done to "vShooterWeapon.cs":
Add this after Effect's header:
[Header("Shell")]
public Transform[] SpawnPoint;
public GameObject[] ShellPrefab;
public GameObject[] ShellClone; And this at the end of StartEmitters() reference:
if (SpawnPoint != null)
{
ShellClone[0] = Instantiate(ShellPrefab[0], SpawnPoint[0].position, SpawnPoint[0].rotation) as GameObject;
}
|
|