RIght now, I want to check if the rotation of the main object, the conveyor, is 90. If it is 90, change the vector3 called direction to have the values -1, 0, 0. If the rotation is 180, change the direction to 0, 0, 1, along with 0 and 270 degrees. Im getting an error that says “Non-Invocable member ‘Vector3’ cannot be used like a method”. How could I get this to work? So far heres my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ConveyorBelt : MonoBehaviour
{
public Transform ConveyorTransform;
public float speed;
public Vector3 direction;
public List<GameObject> onBelt;
void Update()
{
if(ConveyorTransform.rotation.eulerAngles.y == 0){
direction = Vector3(0, 0, -1);
}
if(ConveyorTransform.rotation.eulerAngles.y == 90){
direction = Vector3(-1, 0, 0);
}
if(ConveyorTransform.rotation.eulerAngles.y == 180){
direction = Vector3(0, 0, 1);
}
if(ConveyorTransform.rotation.eulerAngles.y == 270){
direction = Vector3(1, 0, 0);
}
for(int i = 0; i <= onBelt.Count -1; i++)
{
onBelt_.GetComponent<Rigidbody>().velocity = speed * direction * Time.deltaTime;_
}
}
// When something collides with the belt
private void OnCollisionEnter(Collision collision)
{
onBelt.Add(collision.gameObject);
}
// When something leaves the belt
private void OnCollisionExit(Collision collision)
{
onBelt.Remove(collision.gameObject);
}
}