Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, Nymphodora, Quad), 923 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
Camera passing through wall #470947
02/14/18 07:29
02/14/18 07:29
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
I am trying to make it so that if the player moves near a wall, and turns its back toward it while turning its body, the camera following the player will glide along the inside of the wall, pushing itself closer to the player's back, and then backs up to its normal following distance once the player's back is turned away from the wall.

I have a function that mostly does this. However, for some reason, while the player is turning its body while facing its front away from the wall (back toward wall), the camera will go behind the wall for the first 90 degrees on the left side of the turn instead of gliding on the inside of the wall, staying at the same distance behind the player as it would have with no collision detected, but then for the second 90 degrees of the turn on the right, the camera will start doing what I want it to do by gliding on the inside of the wall coming closer to the player's back for the remainder of the turn. It is always the first 90 degrees on the left side of the turn where the camera goes through the wall behind the player (what I do NOT want to happen), and always the second 90 degrees on the right of that same turn where the camera does not go through the wall and instead glides on the inside of the wall (what I would like to happen for the whole 180 degrees of this turn). This happens in the exact same manner from left to right, no matter what the wall, no matter where the wall is.

Here is my camera function:

Code:
void _handle_cam_3rdperson()
{
   c_rotate ( me, vector(-mickey.x * 0.3, 0, 0), IGNORE_ME |
              IGNORE_PASSABLE | IGNORE_SPRITES | USE_POLYGON |
              GLIDE );
		
   my.skNextPan = my.pan;
	
   my.skNextTilt = clamp ( my.skNextTilt - mickey.y * 0.3, 
                              -90, 90 );
   my.skNextRoll = 0; 
	
   VECTOR vecOrigin;	
			
   vec_set ( vecOrigin, vector(5,-25,40) ); 
   vec_rotate ( vecOrigin, vector(my.pan,0,0) ); 
   vec_add ( vecOrigin, my.x ); 	

   VECTOR vecTarget;
   vec_for_angle ( vecTarget, my.skNextPan );
	
   vec_scale ( vecTarget, -80 );
	
   vec_add ( vecTarget, vecOrigin );

   // THIS SEEMS TO BE WHERE THE ERROR LIES		
   var distance = c_trace ( vecOrigin, vecTarget, IGNORE_ME |
                            IGNORE_PASSABLE | IGNORE_SPRITES |
                            USE_POLYGON ); 
	
   if ( HIT_TARGET )
   {
      beep(); // THIS BEEPS DURING THE 2ND 90 DEGREES OF THE TURN IN
              //    QUESTION, NOT DURING THE 1ST 90 DEGREES.

      vec_set ( vecTarget, hit.x );
		
      if ( distance > 0 )
         reset ( me, TRANSLUCENT );
      else
         set ( me, TRANSLUCENT );
   
   }
   else
   {
      reset ( me, TRANSLUCENT );
   }
		
   vec_lerp ( camera.x, camera.x, vecTarget, time_step );
		
   vec_sub ( vecOrigin, camera.x );
   vec_to_angle ( camera.pan, vecOrigin );
}


It appears that this line of code is causing the error in question:

Code:
var distance = c_trace ( vecOrigin, vecTarget, IGNORE_ME |
                         IGNORE_PASSABLE | IGNORE_SPRITES |
                         USE_POLYGON );


The beep() right after the HIT_TARGET beeps like crazy during the 2nd 90 degrees of the turn sensing the collision, but does not beep at all during the 1st 90 degrees of the turn which shows that collision is not being detected. Why is the c_trace line from vecOrigin and vecTarget not being detected during the first 90 degrees of the turn, but is being detected during the second 90 degrees of the same turn?

Any help will be greatly appreciated. Thank you.

Last edited by Ruben; 02/16/18 03:31.
Re: Camera passing through wall [Re: Ruben] #471014
02/16/18 05:21
02/16/18 05:21
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
Okay, made a little progress. I find that altering the xyz coordinates in:
Code:
vector(5,-25,40)


...for this code:
Code:
vec_set ( vecOrigin, vector(5,-25,40) );


...is changing the location of the c_trace line, and making the first part of the turn where the camera is behind the wall last shorter (like maybe first 30 degrees of turn), and more quickly start gliding inside the wall like I want it to (for about the last 110 degrees of the turn). Only thing is that I have to permanently change the camera position to accomplish this. It might work great for turning player with its back facing a wall, but when the player's back faces away from the wall, the camera is not in a position that I want it to be in.

Trying to make it so that the camera does not go through a wall when facing player's back against it during a turn, and also having the camera be where I want it to be when the player's back is facing away from a wall as well.

Last edited by Ruben; 02/16/18 05:23.
Re: Camera passing through wall [Re: Ruben] #471015
02/16/18 05:50
02/16/18 05:50
Joined: Jul 2014
Posts: 72
D
DriftWood Offline
Junior Member
DriftWood  Offline
Junior Member
D

Joined: Jul 2014
Posts: 72
Very old engine means every simple thing is solved already on forum or...
http://opserver.de/twik11/index.php?title=Main_Page
Slin did this 8 years ago
http://opserver.de/twik11/index.php?title=Improved_3rd_Person_Camera
I think superku has done another one.
Then there is always
http://www.coniserver.net/coni_users/web_users/pirvu/aum/aumonline_e/

Re: Camera passing through wall [Re: DriftWood] #471045
02/17/18 04:05
02/17/18 04:05
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
Thank you Driftwood. I will check it out.

Re: Camera passing through wall [Re: Ruben] #471113
02/20/18 01:02
02/20/18 01:02
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
So, it seems I made some progress. I changed this code:
Code:
var distance = c_trace ( vecOrigin, vecTarget, IGNORE_ME |
                            IGNORE_PASSABLE | IGNORE_SPRITES |
                            USE_POLYGON );


...to this:
Code:
var distance = c_trace ( player.x, vecTarget, IGNORE_ME |
                            IGNORE_PASSABLE | IGNORE_SPRITES |
                            USE_POLYGON );


The beep() just after the HIT_TARGET now beeps whenever the camera touches the wall (which is great), and the camera does not go behind the wall (which is also great), at least not entirely (which still gives me an issue).

The issue is, lets say you are the player, and your player's front side is facing a wall. You move your mouse left, making the player rotate left. The camera rotates with and behind the player, facing the player's back at all times, all while the right side of the camera moves closer toward the wall given that the player is rotating. The camera's right side makes contact with the wall, and glides along the wall, making it move closer to the player's back as the player keeps rotating, all the way till the player rotates so far to the point that its back is not facing the wall anymore, at which point the camera detaches from the wall and moves back to its original distance behind the player.

In the first half of this rotation where the camera makes contact with the wall, I can see a vertical sliver of blue on the right side of the screen past the wall (which is not great). The camera is not entirely moving through the wall like before, but it feels like a small section on the right side of the camera is peeking through the wall, as the camera glides along the wall. Once the camera reaches the middle of the rotation, making the camera face directly away from the wall and toward the player's back, the blue disappears (which is great). Once the camera reaches the opposite side of this same rotation, no blueness is present at all (which is great). This gives the feeling like the right side of the camera peeks through the wall, and the left side of the camera does not.

Does anyone have a clue on how to prevent the camera from peeking past the wall for the entire rotation, while the player's back is facing the wall?

Last edited by Ruben; 02/20/18 01:52.
Re: Camera passing through wall [Re: Ruben] #471118
02/20/18 03:03
02/20/18 03:03
Joined: Jul 2014
Posts: 72
D
DriftWood Offline
Junior Member
DriftWood  Offline
Junior Member
D

Joined: Jul 2014
Posts: 72
The solution is to move the camera further away from the wall.

I don't read 3dgs code perfectly anymore.
Ok you seem to be placing the camera right at hit.x or in other words *on the surface of the wall.*

My solution would be to simply move vecTarget closer to the player after the set . Assume the camera has a size of 20.

Vec_set(vecTarget,hit.x)
**Now adjust the vec say 20 closer to the player.
Get the Vector from vecTarget to the player.
Normalize it to 20.
Then vec_add it to vecTarget ?? Or is vec_sub I forget.
Bam! Camera has extra room and is off the surface of the wall.
So I'll have to look at the manual and remember how to do that.

Last edited by DriftWood; 02/20/18 03:04.
Re: Camera passing through wall [Re: DriftWood] #471119
02/20/18 03:17
02/20/18 03:17
Joined: Jul 2014
Posts: 72
D
DriftWood Offline
Junior Member
DriftWood  Offline
Junior Member
D

Joined: Jul 2014
Posts: 72
I'm guessing something like this.
Code:
Vec_set ( vecTarget, hit.x);
Vec_set (temp_vecA, player.x);
Vec_set (temp_vecB, vecTarget);
Vec_sub (temp_vecA, temp_vecB);
Vec_nomalize(temp_vecA, 20);
Vec_add (vecTarget, temp_vecA);
//Now vecTarget "should be" 20 units off the wall and closer to the player.


Other solutions could be putting the camera in abox. Using side traces from the camera. Using 3 traces to the wall and blending the vecTarget further to the open side. Or hiring a virtual monkey to fly the camera in the dangerous isolation of 3dgs space!!!

Re: Camera passing through wall [Re: DriftWood] #471120
02/20/18 03:29
02/20/18 03:29
Joined: Jul 2014
Posts: 72
D
DriftWood Offline
Junior Member
DriftWood  Offline
Junior Member
D

Joined: Jul 2014
Posts: 72
Wait!!! Cool idea! Why not just push off the wall using it's own normal?!
Yeah that could work!
Code:
Vec_set( vecTarget, hit.x);
Vec_set ( vec_temp, hit.nx);
Vec_normalize ( vec_temp, 20);
Vec_add ( vecTarget, vec_temp);
// Bam!!! Virtual Monkey!!!


Re: Camera passing through wall [Re: DriftWood] #471121
02/20/18 03:34
02/20/18 03:34
Joined: Jul 2014
Posts: 72
D
DriftWood Offline
Junior Member
DriftWood  Offline
Junior Member
D

Joined: Jul 2014
Posts: 72
Virtual Monkey freezes and dies in the cold frigid isolation of A8 3dgs space.
Alone and sad his body floats away.

But good news!
Aliens clone virtual monkey and resurrect him in another engines!!
He's saved and happy.

Re: Camera passing through wall [Re: DriftWood] #471126
02/20/18 08:42
02/20/18 08:42
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
Originally Posted By: DriftWood
Wait!!! Cool idea! Why not just push off the wall using it's own normal?!
Yeah that could work!
Code:
Vec_set( vecTarget, hit.x);
Vec_set ( vec_temp, hit.nx);
Vec_normalize ( vec_temp, 20);
Vec_add ( vecTarget, vec_temp);
// Bam!!! Virtual Monkey!!!


Interesting, I never heard of ".nx". I cannot seem to find it in the manual, or online. Where does it discuss the concept of ".nx"?*

Page 1 of 3 1 2 3

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