#Vector casts

1 messages · Page 1 of 1 (latest)

fiery steeple
#

ok post the code lines

#

i will help with it

lusty sphinx
#
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

fiery steeple
#

well instead ofcs Vector3 randomPos;
use Vector2

lusty sphinx
#

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

fiery steeple
#

can you do that

lusty sphinx
#
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);
fiery steeple
lusty sphinx
#

already tried that too

fiery steeple
#

right?

lusty sphinx
#

yeah

fiery steeple
#

and then y with ?

lusty sphinx
#

z

fiery steeple
#

ok so

#
randomPos.x += transform.position.x;
randomPos.y += transform.position.z;```
lusty sphinx
#

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

fiery steeple
#

what does it putput

#

?

#

and ping me

lusty sphinx
fiery steeple
#

well

#

that is supposed to happen

#

you mean the z doesnt work?

lusty sphinx
#

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);

fiery steeple
#
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

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

fiery steeple
lusty sphinx
#

I can grab that position and it's in the right place

fiery steeple
#

try sphere

#

instead of circle

lusty sphinx
#

a sphere wouldn't give even values across the surface

fiery steeple
#

try it out

lusty sphinx
#

oh wait a minute sorry I was still calling randomPos instead of myPos

#

it works now

fiery steeple
#

ok

#

gl

#

bye

lusty sphinx
#

thanks