#Is it possible to make an entity placeable in only 8 directions ?
1 messages · Page 1 of 1 (latest)
Try adding this to your animation file:
"loop": true,
"bones": {
"<put_root_bone_name_here>": {
"rotation": [0, "-q.body_y_rotation + (Math.round(q.body_y_rotation / 45) * 45)", 0]
}
}
}```
However, make sure that this animation is always running otherwise it will have no effect!
How do I make sure it's always running?
Tried adding body rotation axis aligned by itself and with blocked.
And this is what it does.
Without the rotation components. This is trying to place it facing forward
This is just a blank armor stand with armor stand behaviors from block bench.
No geometry change
I made a script that rotates the custom armor stand everytime you use the "spawn egg"
function getblockFace(block,blockFace) {
switch (blockFace) {
case "Up":
return block.above();
case "Down":
return block.below()
case "South":
return block.south()
case "North":
return block.north()
case "East":
return block.east()
case "West":
return block.west()
}
}
world.beforeEvents.playerInteractWithBlock.subscribe(async({player, isFirstEvent, itemStack, block, blockFace})=>{
if (itemStack?.typeId !== "myname:work_please_spawn_egg") return;
await system.waitTicks(0);
const entities = player.dimension.getEntities({
location: getblockFace(block,blockFace).center(),
closest: 1,
type: "myname:work_please",
excludeTags: ["rotated"]
});
if (!entities.length) return;
const rot = player.getRotation().y + 180;
let yRot = 0;
if (rot >= 22.5 && rot < 67.5) yRot = 45
else if (rot >= 67.5 && rot < 112.5) yRot = 90
else if (rot >= 112.5 && rot < 157.5) yRot = 135
else if (rot >= 157.5 && rot < 202.5) yRot = 180
else if (rot >= 202.5 && rot < 247.5) yRot = 225
else if (rot >= 247.5 && rot < 292.5) yRot = 270
else if (rot >= 292.5 && rot < 337.5) yRot = 315
else if (rot >= 292.5 && rot < 337.5) yRot = 315
entities.forEach(entity=>{
entity.setRotation({x:0,y:yRot});
entity.addTag("rotated")
})
})
I Removed
minecraft:body_rotation_axis_alignedandminecraft:body_rotation_blockedcomponent on my end while making these
The rotation wasn't instantaneous unfortunately
Do you want to use this approach instead?
So the axis aligned and blocked actually don't work at all because of the runtime identifier but removing stops it from acting like an armor stand completely.(Cant equip items, no poses, gets hurt animations, dies)
Ill hop on the PC now and check that out. Thank you so much for doing that.
im not sure how do the animation set up, and they never wrote back.
Those component mentioned cardinal direction, which is usually South, East, North, and West. Probably has nothing to do with the runtime identifier. It'll only snaps to those 4 direction
It only snaps to those if I remove the identifier. Otherwise it does the shake thing in the video
And doesn't actually snap at all
This
I would be fine with it only doing the 4 even if the component worked and the entity still acted like an armor stand
Well, an armor stand could still technically rotate outside its usual 8 directions if you use commands...
here the alignment script on action
I've just got my PC loaded up. honestly, That's perfect, thank you! My biggest concern was to just get it to face forward and this achieves that and then some.
This has been stressing me out for a couple weeks. Thank you so much for real!
As this was just a default to try to make sure I was playing no part in it not placing correctly, I assume I can just change the spawn egg and type name to the correct identifiers?
ye
Thank you!!!
i dont get what im doing wrong?
[Scripting][error]-Unhandled promise rejection: ArgumentOutOfBoundsError: Unsupported or out of bounds value passed to function argument [0]. Value: 0, argument bounds: [1, 4294967295.00] at <anonymous> (new.js:50)
what's at line 50
i thought it was saying i was placing it in some crazy location lmao
thank you!
i never thought something as simple as an armor stand facing me would make me so happy. my hero. thank you again
Sorry that I took a while to respond, but if you would like to use the animation method to avoid the jarring rotation alignment that the script method causes, make sure you have something like this in your client entity file:
"scripts": {
"animate": [
"45d_align"
]
},
"animations": {
"45d_align": "animation.armor_stand.45d_align" // Change this to whatever you've named the animation
}```
(this is what I was referring to when I said to make sure that the animation is always running)