Ambiera Forum

Discussions, Help and Support.

Create a new account, Search, or Login:
Name: Password:
Ambiera Forum > CopperCube > Programming and Scripting
How To Set Vertical Camera Limitation
Author Text

baladewa
Registered User
Quote
2022-03-29 07:16:22

I'm new user of this engine. id love to trial error with this engine just because only this engine did good (no bugs/problems) when i created and show in webgl on browser rather then others with bugs. Also i tried with android phone (inside apk) and its still have a fast and good performance. Congratulations!

But i need help about camera setting

I opened a tank scene file that used a model viewer camera type. I need solution how to set this camera not to move below the floor node.

I used an "If below the sea level do something" behaviour to detect camera position, but how to stop the camera node not to go below the sea level?

Maybe there is a script anyone know how. I dont want to see below the 3d object, i just need to rotate left right up and down but not below the floor/sea level

i plan to change the tank object with my gltf house so i dont want to sea below the house just limit above the road.

Thanks.


sven
Registered User
Quote
2022-03-29 09:33:23

there is many ways how to do it..

this version i made checks if camY is lower than camTargetY
(you can adjust it -but make sure your cam pos is not in block zone at startup)

Download project file with script i made.
https://drive.google.com/file/d/...

Script itself:
//Script by sven from ambiera forum.
//for more stuff visit my youtube channel:
//https://www.youtube.com/channel/UCN3jBL46fjoVrtGnpcnCO4w
//also visit my itch page:
//https://5v3n.itch.io/

/*
<behavior jsname="behavior_C_L" description="CL">
<property name="Cam" type="scenenode" default="Camera1" />
<property name="AdjustH" type="int" default="20" />
</behavior>
*/

behavior_C_L = function()
{
this.ly=0;
}

behavior_C_L.prototype.onAnimate = function()
{
var clevel = ccbGetSceneNodeProperty(this.Cam, "Position");
var tlevel = ccbGetSceneNodeProperty(this.Cam, "Target");

if(clevel.y+this.AdjustH<tlevel.y)
{
clevel.y=this.ly;
ccbSetSceneNodeProperty(this.Cam, "Position",clevel);
}

this.ly=clevel.y;
return true;
}



Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Int?rnational" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© 2020 Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact