Jump to content

Create Sphere between 2 positions


Recommended Posts

Posted

Hey!

I can't figure out how to create a sphere between 2 positions (X/Y).

Currently I use createColCuboid and calculate the width and depth like this:

width = math.abs(x1-x2) 
depth = math.abs(y1-y2) 

But when I create a sphere with a command, the sphere sometime gets created to the wrong/opposite side.

For example:

I create a sphere from the station at SF to the police department, but it gets created from the station to the opposite side.

Is there another function to create a sphere with two positions?

Currently working on gamemodes :

  • Reallife Script 70%
  • Breakout Script 10%
Posted

Correct me if I am wrong:

you want to create a sphere using Dx, giving 2 coords > (x,y,z) and (x1,y1,z1) .

and using this 2 coords you get the middle of the line segment, right ? that will be this point : ( (x1-x)/2 , (y1-y)/2 , (z1-z)/2 )

and using this point, you will create the sphere, with that center : ( (x1-x)/2 , (y1-y)/2 , (z1-z)/2 ) and with a given radius, depending on the distance between those points, using square root.

Is that you want ?

Posted

Yes you got it ;D

And how do I calculate the distance now? I tried to use getDistanceBetweenPoints2D/2, but it only returns 1 float.

But i need a width and depth

Currently working on gamemodes :

  • Reallife Script 70%
  • Breakout Script 10%
Posted

Just tried it^^

The problem is that (x1-x)/2 , (y1-y)/2 , (z1-z)/2 is not the center of those points :/

But the width and height is ok now :)

Currently working on gamemodes :

  • Reallife Script 70%
  • Breakout Script 10%

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...