#Simplified Camera Presets In Script API

1 messages · Page 1 of 1 (latest)

wise tangle
#

Can you please mention what are those presents and how to use them?

marsh solar
#

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
upbeat forge
#

thank you so much

#

i just realized this is made of js and i cant utilize it gx_Sunglasses_cry

upbeat forge
marsh solar
#

I could probably help you

upbeat forge
marsh solar
#

Alright then

upbeat forge
#

@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)

marsh solar
upbeat forge
#

the camera position is decided using scoreboard

marsh solar
#

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

upbeat forge
#

im fine with overriding camera

#

i have custom presets

marsh solar
#

Alright then. Let me get this for you then. I'm assuming this camera should also work on a certain scoreboard value

upbeat forge
#

yep

#

there are 4 camera positions

marsh solar
#

Its Basically The Same Camera In The Video You Showed Me But Has The CanBlockObstructView Being Used

upbeat forge
#

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

marsh solar
#

Yea Np

somber plaza
marsh solar
somber plaza
#

I tried to put the script and the manifest but when I enter it it doesn't work

marsh solar
#

Let Me Make A Quick Example

upbeat forge
#

@marsh solar i found an issue, if the camera enters into water block, the script crashes

marsh solar
#

Which Camera Method Were You Using

upbeat forge
#

i would love to send a vid but my phone has low battery so it wont allow me to record

upbeat forge
marsh solar
#

I See. You Are Very Much So Correct Let Me Fix This. Thank You For Notifing Me Of This Bug

upbeat forge
#

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

marsh solar
#

Could I See What You Wrote Inside The Camera Method. Or Is It Exactly The Same

upbeat forge
#

its exactly the same, just with different scoreboard objective

marsh solar
#

Just To Make Sure Of This You Mean This One

upbeat forge
#

yep that one

#

i forgot to mention i put that in main js

#

instead of camera class js

marsh solar
#

That's Fine. That Shouldn't Affects Things As I'm Aware Of.

upbeat forge
#

phew

marsh solar
#

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

marsh solar
# upbeat forge phew

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 } } })

upbeat forge
#

can you tell me the difference?

marsh solar
#

I Removed The OffsetX And OffsetZ And Readjusted The PlayerLocation XYZ Values. Also I Change Range From 8 To 9

upbeat forge
#

oh wait that was range?

#

i didnt read the code enough facepalm

#

alr ty ill brb with results rq

marsh solar
#

Cool

upbeat forge
#

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?

upbeat forge
#

oh yeah nevermind, isSolid property is for experimental only

upbeat forge
#

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

upbeat forge
marsh solar
#

I forgot to send the updated camera script

upbeat forge
#

its updated?

marsh solar
upbeat forge
#

oh yeah i actually modified it to do that

marsh solar
upbeat forge
#

i suppose

upbeat forge
#

works the best if you make a vertical hole and place torches

marsh solar
#

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

upbeat forge
#

for some reason it just freezes and watchdog kills it

marsh solar
#

Could you show me a video of it.

upbeat forge
#

hold on

marsh solar
#

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"];```

upbeat forge
#

actually i figured it out, ty

thick mango
#

Is the CameraAttachToEntity suppose to make the camera follow a moving entity?

sturdy oasis
#

Why is there so many undefined variables

marsh solar
sturdy oasis
marsh solar
#

The Code Is Just Written In JavaScript And Not In TypeScript

#

So Their Could Be Differences I Don't Even Know

sturdy oasis
#

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

sturdy oasis
marsh solar
# sturdy oasis

Okay I Think I Fixed Them. For Some Reason My Debugger Wasn't Highlighting Them By Mistake. Thanks For Notifing Me About This

upbeat forge
#

nice

#

does this fix the crash issue by resetting the camera?

upbeat forge
#

oh wait its for beta

marsh solar
# upbeat forge 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.

upbeat forge
#

hmmmm i should be careful with overwriting then...

#

ill take a closer look once i finish the stuff im doing rn

marsh solar
#

I Mainly Improved The CameraAttachToEntity And BehindPlayerFocusOnEntity Methods.

#

Also Added Some Instructions To CameraCinemaViewingInstructions Method

short sable
#

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.

marsh solar
marsh solar
short sable