So basically the code is for a football game that I’m making in VR, and I’m trying to make the ball act realistic when thrown. so basically the ball will spiral and the nose of the ball will change its direction based on face velocity. and im trying to make it so when its thrown, it will start the start functions in my script, and when its not being held then it will start the stop functions in my script. Im going based off this video so hopefully this helps you understand what im talking about -XR Toolkit - Basic Programming [01] by Andrew
Here is my script too
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Security.Cryptography;
using UnityEngine;
public class Spin : MonoBehaviour
{
float spin;
float spinspeed;
Vector3 facing;
Rigidbody rb;
private bool CanStartVelocity = false;
private bool CanStartSpin = false;
// Use this for initialization
void Start()
{
rb = GetComponent<Rigidbody>();
StopFaceVelocity();
StopcanSpin();
}
// Update is called once per frame
void Update()
{
}
public void StartcanSpin()
{
if (CanStartSpin = true)
{
StartcanSpin() = true;
spin = 1f;
spinspeed = 20f;
}
}
public void StartFaceVelocity()
{
if(CanStartVelocity = true)
{
StartFaceVelocity() = true;
facing = Quaternion.LookRotation(rb.velocity).eulerAngles;
spin += Time.deltaTime * spinspeed;
if (spin > 360f) { spin = spin - 360f; }
transform.eulerAngles = new Vector3(facing.x, spin, facing.z);
}
}
public void StopFaceVelocity()
{
if(CanStartVelocity = false)
{
FaceVelocity() = false;
}
}
public void StopcanSpin()
{
if(CanStartSpin = false)
{
StartcanSpin() = false;
}
}
}
Also if you find anything else with the script that is wrong, please tell me. Because its giving a lot of errors which is forcing me to enter safe mode. Thank you!