#Vector casts
1 messages · Page 1 of 1 (latest)
Vector3 randomPos = (Random.insideUnitCircle * spawnRadius);
this is how I'm getting the circle
although I actually found out that it uses x,y instead of x,z
well instead ofcs Vector3 randomPos;
use Vector2
right but, I'm trying to deal with 3D coordinates
I don't have an issue with that line
but when I try to add that to the position of the place I actually want the circle to be centred around it doesn't work
well i told you to send the code snippet that uses this info
can you do that
Vector3 randomPos = (Random.insideUnitCircle * spawnRadius);
randomPos = randomPos + (transform.position);
sure thing
this doesn't work though
I've tried a few different approaches
I've also tried
Vector3 randomPos = transform.position + (Random.insideUnitCircle * spawnRadius);
Vector2 randomPos = Random.insideUnitCircle * spawnRadius;
randomPos += transform.position;
yeah
and then y with ?
z
ok so
randomPos.x += transform.position.x;
randomPos.y += transform.position.z;```
that doesn't factor in the vector3 which I want to center these coordinates around
and that doesn't actually seem to even put the y into the z
wdym?
what does it putput
?
and ping me
I think you're getting y and z mixed up
y is the second coordinate
if that code worked as intended it have the y as 0
also that is still just around the worlds origin
which means the extra two lines didn't do anything that wasn't accomplished in Vector3 randomPos = (Random.insideUnitCircle * spawnRadius);
Vector2 randomPos = Random.insideUnitCircle * spawnRadius;
Vector3 myPos;
myPos.x = randomPos.x + transform.position.x;
myPos.z = randomPos.y + transform.position.z;
myPos.y = transform.position.y;
@lusty sphinx
yeah, this is still just doing the same as
Vector3 randomPos = Random.insideUnitCircle * spawnRadius;
I forgot to say it's actually player.transform.position but even adding that didn't change anything
are you sure the problem is here?
I can grab that position and it's in the right place
well
try sphere
instead of circle
a sphere wouldn't give even values across the surface
well
try it out
thanks