Reputation: 513
hey I saw someone do this
// bullet is speed 5, aimed at timmy:
float3 v = ((timmy.transform.position - transform.position).Normalized)*5;
bullet.velocity = v;
the transform.position are Vector3(float x, float y, float z);
so i thought i could do this
private float3 _position;
public Food ()
{
float3 position = _position(0.0f,0.0f,0.0f);
}
but that says: The type or namespace name `float3' could not be found. Are you missing a using directive or an assembly reference?
so how would i let one variable take multiple values of the same type?
Upvotes: 1
Views: 1479
Reputation: 4744
You have multiple possibilities.
You can declare a class (or a struct):
public class float3
{
public float X { get; set; }
public float Y { get; set; }
public float Z { get; set; }
}
You can use an array:
private float[] _position;
public Food ()
{
_position = new[] {0.0f,0.0f,0.0f};
}
Or you can use a tuple
private Tuple<float,float,float> _position;
public Food ()
{
_position = Tuple.Create(0.0f,0.0f,0.0f);
}
Upvotes: 2