Method Must have a Return Type (Vector3 x,y,z)

So i’ve been trying to figure this out for 3hours now and I cant figure it out.
My idea is that I have this cube . and when I push it a distance away from it’s original position. It destroys itself. But I got a problem. I think im on to something, but I dont know how to fix this error

(If Im doing this completely wrong, Tell me. I havent used C# ever before , and Im trying to figure this out…)

using UnityEngine;
using System.Collections;

public class BreakableObject : MonoBehaviour {

	[HideInInspector] int startPosX;
	[HideInInspector] int startPosY;
	[HideInInspector] int startPosZ;

	public Vector3(float x, float y , float z) // Error here. (Must have Return type)
	
// Use this for initialization
	void Start () {
		startPosX = Vector3.x;
		startPosY = Vector3.y;
		startPosZ = Vector3.z;
	}
	// Update is called once per frame
	void Update () {
		if ((Vector3.x ^ Vector3.y ^ Vector3.z) < (startPosX ^ startPosY ^ startPosZ))
		{
			Object.Destroy (this.gameObject);
		}
		if ((Vector3.x ^ Vector3.y ^ Vector3.z) > (startPosX ^ startPosY ^ startPosZ))

		{
			Object.Destroy (this.gameObject);
		}
	}
}

that’s not how you define a Vector3, if that’s the intent.

something like this:

public Vector3 MyVector3Variable;

then in Start()/Update() reference it like this:

void Start()
{
    startPosX = MyVector3Variable.x
   ...
}

however, you’ll need to use float’s and not int’s if you want any sort of accuracy/it to work at all :wink:

and when you’re comparing, you need to think about what you’re testing against - your Vector3 being greater/less than something isn’t (usually) practical.

what are you trying to achieve here? two positions not being (approximately) equal?

for your future sanity, might i suggest you run through a few of the unity tutorials - they’re a good introduction to unity & c# and should help you get more familiar with the syntax.

I think you’re looking for something like this:

public class BreakableObject : MonoBehaviour {

    public float moveLimit = 1; // distance to move before deleting
    private Vector3 startPos;
	
	void Start()
	{
	    startPos = transform.position;
	}
	
	void Update()
	{
	    if (Vector3.Distance(startPos, transform.position) > moveLimit)
		{
		    Object.Destroy(this.gameObject);
		}
	}
}