#Simplified Camera Presets In Script API
1 messages · Page 1 of 1 (latest)
Updated:
- Moved -- > UseCameraFunction Parameter As An Optional Parameter.
- Added --> CanBlockObstructView As An Optional Parameter. This New Feature Allows The FocusEntity/FocusLocation Camera To Go Closer Towards The Player If The Camera In Itself Is Inside Of A Block. This Feature Is Defaulted To False, Which Automatically Applies To Your Focus Camera Present. You Can Always Make The Camera Go Through Blocks By Simply Making CanBlockObstructView As True In Its Optional Parameter
holy this is gonna be really useful
thank you so much
i just realized this is made of js and i cant utilize it 
It's not that hard
well i dont have any knowledge in javascripts
I could probably help you
nah i think its alright
Alright then
@marsh solar ...actually, i do need help with it
first of all, how do i use this? 🤔 (like from the beginning)
to be more specific, im making this thing with command blocks (will be replaced with functions)
there are 4 different camera on fixed positions and the player can adjust the position by setting the scoreboard value
the camera would make use of CanBlockObstructView parameter, but only if the obstacle is big enough to cover the player (a pillar wouldnt affect the camera)
So If I'm getting this right you want to use the canblockobstructview parameter while using your command camera
youve got it right
the camera position is decided using scoreboard
Well the canblockobstructview parameter is Inside of two methods behindtheplayerfocusonentity and behindplayerfocusonlocation. So these camera methods would require to override your command camera in order to use. Which is something you probably don't want
Alright then. Let me get this for you then. I'm assuming this camera should also work on a certain scoreboard value
Its Basically The Same Camera In The Video You Showed Me But Has The CanBlockObstructView Being Used
yeah uh i forgot to mention the camstate objective is for first person and stuffs...
and each score (1, 2, 3, 4) gives different position of the camera
will it work fine if i change the camstate with something else
oh yeah i just reread it and
meh testing is the only way here, thank you so much ily
Yea Np
How can I use this in my survival world?
Well You Would Need To Have A Addon/Project. Then Your World Would Have To Be Using The Beta-Api In Experimentals. Then If Your Javascript File You Would Just Need To Import This Class.
I tried to put the script and the manifest but when I enter it it doesn't work
Let Me Make A Quick Example
@marsh solar i found an issue, if the camera enters into water block, the script crashes
Let Me Test This Theory
Which Camera Method Were You Using
i would love to send a vid but my phone has low battery so it wont allow me to record
the one you gave me above
I See. You Are Very Much So Correct Let Me Fix This. Thank You For Notifing Me Of This Bug
np
oh and also if the camera enters a block it just moves into player and face downwards
not sure if i configured it wrong but yeah
Could I See What You Wrote Inside The Camera Method. Or Is It Exactly The Same
Just To Make Sure Of This You Mean This One
yep that one
i forgot to mention i put that in main js
instead of camera class js
That's Fine. That Shouldn't Affects Things As I'm Aware Of.
phew
I Mean Its Suppose To Zoom In. But In The Video It Does Appear That The Logic Could Be Flawed. Or It Could Be Possibly The Camera Angle
Try This js system.runInterval(() => { for (const players of world.getAllPlayers()) { const Camstate = getScore(players, "camstate") if (Camstate === 1) { const PlayerLocation = { x: players.getHeadLocation().x + 1, y: players.getHeadLocation().y - 3, z: players.getHeadLocation().z + 1 } const Camerafunction = new Camera(players).BehindPlayerFocusOnLocation(PlayerLocation, 9, { CanBlockObstructView: false}) Camerafunction } } })
can you tell me the difference?
I Removed The OffsetX And OffsetZ And Readjusted The PlayerLocation XYZ Values. Also I Change Range From 8 To 9
oh wait that was range?
i didnt read the code enough 
alr ty ill brb with results rq
Cool
@marsh solar
it works now
but theres still an issue where the script freezes when the camera enters into water
maybe i could add passable blocks on the whitelist?
oh yeah nevermind, isSolid property is for experimental only
replacing the the property that checks air block id with TestBlock.isAir || TestBlock.isLiquid === true solved the script freezing
and also i found the bug reason
if the camera moves towards player until the minimum distance possible and return true for testblock, the script runs into loop and dies
...hey wait, i can run this without beta api though
Yeah. It should work
I forgot to send the updated camera script
its updated?
Yea. It change the script to allow air, water, and lava to function as normal
oh yeah i actually modified it to do that
this one
But everything is good now
i suppose
though theres still this
works the best if you make a vertical hole and place torches
Well if the camera can't find a location that's not the exactly to to close to the player. The Script will just make the camera go to the players location. Otherwise it'll adjust to a possible location
for some reason it just freezes and watchdog kills it
Could you show me a video of it.
Yeah So. A Defiant Fix Would Be To Change The IsInsideBlock Check For The Block Using IsSolid Which Would Require Experimentals. However There's Another Way Of Doing This For Stable: ```js
function IsInsideBlock(CameraPosition) {
const TestBlock = world.getDimension(Player.dimension.id).getBlock(CameraPosition);
const BlockList = ["minecraft:air", "minecraft:water", "minecraft:lava"];
if (BlockList.includes(TestBlock.typeId)) {
return false
} else {
return true
}
}``` As You Seen Inside The BlockList Array You Can See The Minecraft Id's. You Can Simply Add The Minecraft Id That Should Allow The Camera Functioj To Fo Through The Block. So In Your Case With Torches Just Make It This ```js
const BlockList = ["minecraft:air", "minecraft:water", "minecraft:lava", "minecraft:torch"];```
hmm where should i put this?
actually i figured it out, ty
Is the CameraAttachToEntity suppose to make the camera follow a moving entity?
Yea
Why is there so many undefined variables
Where Exactly
Copy the code and paste it in a typescript file. It will show you all the undefined variables
The Code Is Just Written In JavaScript And Not In TypeScript
So Their Could Be Differences I Don't Even Know
Nope there's no differences
Typescript is just more strict about typings and type errors
So with typescript you can see all those errors you left in the code easily
Thats Cool
Okay I Think I Fixed Them. For Some Reason My Debugger Wasn't Highlighting Them By Mistake. Thanks For Notifing Me About This
Np :)!
oh wait its for beta
I'm Pretty Sure It Does. However If It Does Occur Again Just Let Me Know. Someone Was Suggesting Some Stuff. So I Was Able To Make Some New Additions. And Obliviously Some Of The Undefined Variables Were Removed Or Changed.
hmmmm i should be careful with overwriting then...
ill take a closer look once i finish the stuff im doing rn
I Mainly Improved The CameraAttachToEntity And BehindPlayerFocusOnEntity Methods.
Also Added Some Instructions To CameraCinemaViewingInstructions Method
This is extremely cool, but I'm wondering: is there any way to make the camera movement follow an entity smoothly? Not sure if I am not putting on a correct argument.
Which Camera Method Are You Trying To Use That's Not Making A Smooth Transition
Because There's Some Stuff You Can Edited Like The EaseTime Which Could Help Make It Smoother. And Some Other Things In General
Yeah, I figured it out already. Thanks tho!