My goal is to use ArmorStands wearing elytra for ray casting. So far I figured out how to make it travel horizontally in any direction. But my problem is that the speed of the entity changes and it results in a curved path when I try to make it travel other pitches than straight horizontal. The method I use teleports the entity upwards every tick by a fixed amount as it glides.
What I can change with commands:
- initial vertical momentum
- entity rotation
- upwards teleport amount
So I'd need the X and Z components of the momentum to be constant for this to be viable. Because I can counteract the Y momentum with the teleportation but not the X or Z. As long as the tp value can be calculated as some polynomial with trig-functions it's feasible to implement it.
How could I determine at what pitch does the X and Z momentum stay constant?
Here's a simplified snippet from the MCP:
Vec3d Look = getLookVec()f = rotationPitch * 0.017453292 # pi/180LookHorizontal = sqrt(Look.xCoord * Look.xCoord + Look.zCoord * Look.zCoord)MotionHorizontal = sqrt(motionX * motionX + motionZ * motionZ)LookLength = Look.lengthVector()PitchCos = MathHelper.cos(f)PitchCos = PitchCos * PitchCos * min(1.0, LookLength / 0.4)motionY += -0.08 + PitchCos * 0.06if (motionY < 0.0 and LookHorizontal > 0.0) #Moving DOWN and not looking straight up or down{ d2 = motionY * -0.1 * PitchCos motionY += d2 motionX += Look.xCoord * d2 / LookHorizontal motionZ += Look.zCoord * d2 / LookHorizontal}if (f < 0.0) #Looking UP{ d9 = MotionHorizontal * -sin(f) * 0.04 motionY += d9 * 3.2 motionX -= Look.xCoord * d9 / LookHorizontal motionZ -= Look.zCoord * d9 / LookHorizontal}if (LookHorizontal > 0.0) #Not looking straight up or down{ motionX += (Look.xCoord / LookHorizontal * MotionHorizontal - motionX) * 0.1 motionZ += (Look.zCoord / LookHorizontal * MotionHorizontal - motionZ) * 0.1}motionX *= 0.99motionY *= 0.98motionZ *= 0.99moveEntity(motionX, motionY, motionZ)