9

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/180
LookHorizontal = 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.06

if (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.99
motionY *= 0.98
motionZ *= 0.99
moveEntity(motionX, motionY, motionZ)
2
  • 7
    I'd say your best bet is to not use an elytra, but just move the entity by a particular amount each tick
    – Venya
    Dec 25 '16 at 21:19
  • I agree with @Venya I would reccomend you to use the TP command
    – BRHSM
    May 15 '17 at 6:41
1

Sorry to burst your bubble, but the Elytra can't be put on Armor Stands.

Also, you can't determine when X and Z postistions are constant. Remember that the Elytra don't give you the ability to actually fly (minus Creative mode), they only allow you to glide. And noting that they take up the Chestplate armor slot still makes players question why the Elytra can't be put on ArmorStands in the first place. The ability to but them on the stands may be in a future update. I tried this with my own game, and I came out with negative results. I died doing this, since Creative mode really makes the Elytra, um, unusable. Survival mode was the only way to do this.

1
  • 3
    Hi NightcoreGaming, welcome to Arqade! I've combined your answers together - we're not like a forum where replies will automatically end up under one another - each answer should stand on it's own. You can always edit your own answers to include more information if you wish.
    – Robotnik
    Jul 31 '17 at 23:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.