- Home /
VR Weapons. New to Unity and need help.
Hello. I'm doing a school project and I'm tasked with creating a virtual reality weapon system. However, I have nearly zero knowledge of coding and Unity software. I've figured out how to pick up the weapons so far by throwing prefabs together using Oculus Integration. I'm not great at coding and we aren't allowed to spend any money on assets. We are only allowed to use free ones. This is due by the end of the year and I'm not sure I can finish it even by then. Thank you for your help
Answer by TicklePickle · Mar 25, 2019 at 07:06 PM
There is a free asset that might be worth looking at: https://assetstore.unity.com/packages/templates/systems/easy-weapons-19365
hope this helps.
I have tried using this and remapping the controls to work with the Oculus Rift touch controllers, but the controls still won't work with it. Could there be anything that I'm doing wrong?
Try "Anthony VR" - he has a You Tube channel and is pretty good at answers and is certainly an expert in this field as I am not...his link is here; https://www.youtube.com/channel/UCG8bDPqp3jykCGbx-CiL7VQ
I wish you luck.........sorry I could not be of further help.
Answer by DDorukA · Apr 06, 2019 at 01:11 AM
For the scripting part you should create a weapon script with variables and a trigger method to hit objects. Here is a simple example that is working.
public class MeleeWeapon : MonoBehaviour
{
public int weapondmg = 100;
void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Player"))
{
other.gameObject.GetComponent<PlayerBeh>().TakeDamage(weapondmg);
}
}
}
You also need a script for your objects or players to be destroyed or take damage from the weapons. Here I am using a script to call TakeDamage function of PlayerBeh script.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Weird behaviour with OnTriggerEnter 0 Answers
Distribute terrain in zones 3 Answers
level doesn't work after reloading 1 Answer
How do I check if a SteamVR HMD and controllers are active? 1 Answer