Team Spartan Cookies & Milk Forums
Holo orbit problem - Printable Version

+- Team Spartan Cookies & Milk Forums (https://teamscm.co.uk)
+-- Forum: Garry's Mod (https://teamscm.co.uk/forum-4.html)
+--- Forum: Expression 2 (https://teamscm.co.uk/forum-6.html)
+--- Thread: Holo orbit problem (/thread-352.html)



Holo orbit problem - The Crowbar Overlord - 13-06-2014

I have a small problem I encountered while creating holograms on an E2 Chip.

The object (Cube) is orbiting around the center of another object (Sphere).
It works completely fine on the X and Y axis, but if I try to do anything on the Z axis, it always spirals out of sight and resets in it's starting position.

The code is the following:

interval(10)

Timer = Timer + 1 * 0.1
T = Timer
Count += 0.01

X1 = 0
Y1 = 0
Z1 = 0

##Orbiting Objects

X2 = 100 * cosr(Count)
Y2 = 100 * sinr(Count)
Z2 = 0

holoPos(43,holoEntity(1):pos() +vec(0,0,0) +vec(X2,Y2,Z2))

__
Is it possible to create a wobbly or tilted orbit around the Sphere?


RE: Holo orbit problem - pho - 13-06-2014

can you give me the entire code ?


RE: Holo orbit problem - Cobra - 13-06-2014

I did the math on my own for this:

Code:
interval(10) AnglePerTick = 1 CurTick = CurTick + 1 Radius = 100 relXPos = cos(CurTick * AnglePerTick) * Radius relZPos = sin(CurTick * AnglePerTick) * Radius holoPos(43, vec(relXPos, 0, relZPos))

You will have to make CurTick persistant in order that it works correctly. This is just some pseudo code I wrote without testing it, so maybe you will need to make some adjustements. (Did not code E2 in a long time, mostly into SF atm)


RE: Holo orbit problem - The Crowbar Overlord - 13-06-2014

Thanks, Cobra! That worked perfectly!