Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,403 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How do I make the camera stay inside the walls? #276986
07/07/09 10:12
07/07/09 10:12
Joined: Mar 2006
Posts: 321
Norway
Eagelina Offline OP
Senior Member
Eagelina  Offline OP
Senior Member

Joined: Mar 2006
Posts: 321
Norway
I am trying out a camera code that I found in the Aums.

How do I stop the camera from going outside the walls of a house?

I only whant it to stay inside , because now when the player are to close to a wall the camera goes outside....and then I cant see the player....

Code:
if (camera_number == 3) // isometric view

               {

                       camera.x = player.x - 350 * cos(player.pan); // 200 = distance

                       camera.y = player.y - 350 * sin(player.pan); // same value here

                       camera.z = player.z + 200; // above the player 200

                       camera.pan = player.pan;

                       camera.tilt = -30; // look down at the player -30

                       camera.roll = 0;

               }




A6 and A7 Commercial
-------------------
Programmer always searching for more to learn and understand. smile
Re: How do I make the camera stay inside the walls? [Re: Eagelina] #277003
07/07/09 11:22
07/07/09 11:22
Joined: Aug 2008
Posts: 2,838
take me down to the paradise c...
Cowabanga Offline
Expert
Cowabanga  Offline
Expert

Joined: Aug 2008
Posts: 2,838
take me down to the paradise c...
Put this line in function main:
Code:
camera.clip_near = 0;



Re: How do I make the camera stay inside the walls? [Re: Cowabanga] #277005
07/07/09 11:32
07/07/09 11:32
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
VeT Offline

Serious User
Happy Birthday VeT  Offline

Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
I think, he(or, probably, she) means than camera moves through the walls.

2 Eagelina: you need to trace from player to camera position and move camera to the target pos (if i understnd correctly, what you need).


1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
Re: How do I make the camera stay inside the walls? [Re: Cowabanga] #277006
07/07/09 11:34
07/07/09 11:34
Joined: Mar 2006
Posts: 321
Norway
Eagelina Offline OP
Senior Member
Eagelina  Offline OP
Senior Member

Joined: Mar 2006
Posts: 321
Norway
No camera.clip_near = 0; didnt work. Did even try to put it inside my cameracode.

I start the game inside a hollow box (that is the house). And when I turn the player when it stands close to the wall, the camera goes outside the box and I cant see the player.... only see the other 3 walls and floor.

Last edited by Eagelina; 07/07/09 11:35.

A6 and A7 Commercial
-------------------
Programmer always searching for more to learn and understand. smile
Re: How do I make the camera stay inside the walls? [Re: VeT] #277008
07/07/09 11:36
07/07/09 11:36
Joined: Mar 2006
Posts: 321
Norway
Eagelina Offline OP
Senior Member
Eagelina  Offline OP
Senior Member

Joined: Mar 2006
Posts: 321
Norway
@VeT

Yes that is what I am looking for. A way to force the camera to stay inside al the time....

Sorry for asking but can you write a "fake/psedo" code to show what you mean. I read code better than text.... smile

Last edited by Eagelina; 07/07/09 11:38.

A6 and A7 Commercial
-------------------
Programmer always searching for more to learn and understand. smile
Re: How do I make the camera stay inside the walls? [Re: Eagelina] #277012
07/07/09 11:52
07/07/09 11:52
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
VeT Offline

Serious User
Happy Birthday VeT  Offline

Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
Here is example of code that you need: http://www.gstools.de/aum/aum82/questions_from_the_forum.htm

function avoid_obstacles()
Code:
function avoid_obstacles()

{

       vec_set (temporary_distance.x, camera.x);

       temporary_distance.z -= 50; // sets a position closer to the feet of the player; 50 = experimental value

       distance_traced = c_trace (player.x, temporary_distance.x, IGNORE_ME | IGNORE_PASSABLE); // trace between the player and temporary_distance

       if (distance_traced == 0) // no obstacles on the way?

       {

               my.alpha = minv(100, my.alpha + 3 * time_step); // then increase player's alpha up to 100

               if (player.alpha == 100) 

               {

                       reset(player, TRANSLUCENT);

               }

               else 

               {

                       set(player, TRANSLUCENT);

               }

               if (camera_distance < my.skill40) // if the camera got closer to the player

               {

                       camera_distance += 1; // restore the initial camera_distance slowly

               }

       } 

       else // obstacles encountered?

       {

               distance_traced -= 2; // then bring the camera 2 quants closer to the player!

               my.alpha = (distance_traced / (my.skill40 + 1)) * 100; // decrease player's alpha; don't allow a division by zero

               camera.x = player.x - distance_traced * cos(camera.pan); // place the camera behind the player

               camera.y = player.y - distance_traced * sin(camera.pan); // at the new distance given by distance_traced

       }

}




1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
Re: How do I make the camera stay inside the walls? [Re: VeT] #277025
07/07/09 12:26
07/07/09 12:26
Joined: Mar 2006
Posts: 321
Norway
Eagelina Offline OP
Senior Member
Eagelina  Offline OP
Senior Member

Joined: Mar 2006
Posts: 321
Norway
Yes thats the code from the morrowin ....
And now I understand.

Thanks smile


A6 and A7 Commercial
-------------------
Programmer always searching for more to learn and understand. smile
Re: How do I make the camera stay inside the walls? [Re: Eagelina] #277026
07/07/09 12:27
07/07/09 12:27
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
VeT Offline

Serious User
Happy Birthday VeT  Offline

Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
You're wellcome smile


1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1