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
2 registered members (Imhotep, opm), 785 guests, and 4 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 2 1 2
How to confirm collision with level blocks? #443852
07/26/14 11:50
07/26/14 11:50
Joined: Jun 2014
Posts: 97
Lagos, Nigeria
T
tolu619 Offline OP
Junior Member
tolu619  Offline OP
Junior Member
T

Joined: Jun 2014
Posts: 97
Lagos, Nigeria
I'm working on a wall-running feature in a 3D game. When the player presses the button, the monster dashes forward. If he bumps into a wall, he should start his wall-run, otherwise he should continue in his normal state. I tried to use hit.nx so I could get the normal to the hit surface and rotate the monster's tilt to be parallel to that normal. The problem is hit.nx seems to only return a value if an entity was hit, but not if a level block was hit. That's exactly the opposite of what I'm trying to do.
A better way to go about this please?
Code:
if(my.state == 12) //Obilicleon Wall-Running
        {
        	while(key_enter || joy_3)
		    wait(1);
	       	
	       	while(my.state == 12)
	       	{
	       		while((dash<100) && WallRunning == 0)
	       		{
	       			dash += 10 * time_step;
	   		        my.animation = 75; //75% animation frame is run3
	   		        ent_animate(me, "run", my.animation, 0);
	   	            c_move(me, vector(dash*time_step, 0, 0), vector(0, 0, -distancedown), USE_POLYGON |IGNORE_PASSABLE);
	                if((dash > 100) && (hit.nx != 0))
	                {
	                	dash = 0; my.animation = 0; WallRunning = 1;
	                	my.roll += 90; //temporary. Will replace with code to orient model to normal of hit surface
	       	            CameraChaseWallRun(me);
	                }
	                else if((dash>100) && hit.nx == 0)
	                {my.state = 3;} //state that waits for button release before reverting to state 1
	                wait(1);
       			}
....rest of wall-run state code
	       	}

}


Re: How to confirm collision with level blocks? [Re: tolu619] #443855
07/26/14 14:15
07/26/14 14:15
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline
Serious User
DLively  Offline
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
Use a c_trace, and trace in front of the monster, if there is something withing the trace (ie a wall) then do the next set of steps.


A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: How to confirm collision with level blocks? [Re: DLively] #443919
07/27/14 22:16
07/27/14 22:16
Joined: Jun 2014
Posts: 97
Lagos, Nigeria
T
tolu619 Offline OP
Junior Member
tolu619  Offline OP
Junior Member
T

Joined: Jun 2014
Posts: 97
Lagos, Nigeria
Right now, I'm using this code snippet but it returns a value whether or not I hit a wall
Code:
var wall;
wall = c_trace(my.x,vec_rotate(vector(100,0,0),my.pan),IGNORE_ME|IGNORE_PASSABLE|IGNORE_CONTENT|IGNORE_MODELS);


While we're at it, after using a c_trace, I want to store the pointer to hit. I can't use ENTITY* or something similar. Please what kind of variable can I store it in?

Re: How to confirm collision with level blocks? [Re: tolu619] #443922
07/27/14 22:47
07/27/14 22:47
Joined: Jun 2014
Posts: 97
Lagos, Nigeria
T
tolu619 Offline OP
Junior Member
tolu619  Offline OP
Junior Member
T

Joined: Jun 2014
Posts: 97
Lagos, Nigeria
I think EVENT_BLOCK is activated just by my entity's feet being in contact with the regular floor. I just tried this and I get a "met a wall" message every frame.
Code:
function ObilicleonWallRun()
{
	if(event_type == EVENT_BLOCK)
	{
		WallRunning = 1;
		printf("Met a wall");
	}
}



THEN WITHIN THE MONSTER'S ACTION CODE...
if(my.state == 12) //Obilicleon Wall-Running
        {
        	while(key_enter || joy_3)
		    wait(1);	
		    
	       	WallRunning = 0; dash = 0; my.z += 20;
	       	my.emask |= ENABLE_BLOCK;
	       	my.event = ObilicleonWallRun;
	       	
	       	while(my.state == 12)
	       	{
	       		while((dash<100) && WallRunning == 0)
	       		{
	       			my.red += 10; my.ambient = 100; my.lightrange = 100;
	       			dash += 12 * time_step;
	   		        my.animation = 75; //75% animation frame is run3
	   		        ent_animate(me, "run", my.animation, 0);
	   	            c_move(me, vector(dash*time_step, 0, 0), vector(0, 0, -distancedown), USE_POLYGON |IGNORE_PASSABLE | IGNORE_SPRITES);
	   	            
	   	            if((dash>100) && WallRunning == 0)
	   	            {
	   	            	my.red = 0; my.ambient = 0; my.lightrange = 0; my.state = 3;
   	            	} //leave wall-running state because he didn't meet a wall

....rest of wall-run code here assuming he doesn't leave the wall-running state
}



Re: How to confirm collision with level blocks? [Re: tolu619] #443926
07/28/14 02:59
07/28/14 02:59
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline
Serious User
DLively  Offline
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
Code:
var wall;
wall = c_trace(my.x,vec_rotate(vector(100,0,0),my.pan),IGNORE_ME|IGNORE_PASSABLE|IGNORE_CONTENT|IGNORE_MODELS);



The reason this will not work is because you are tracing 100 quants on the x axis, rather than in front of the entity itself.

In order to trace in front of the entity, you will need to use some trig first, and store it inside a VECTOR, and trace from my.x, to the VECTOR you've created.

As old as this AUM is, it covers basic trig to achieve what you will need in order to get the correct direction for your trace.

Also, you can check to see if your trace has hit something, like this:

Code:
result = c_trace(my.x, trace_distance.x, FLAGS);
if(result > 0){beep();}//Hit something



Originally Posted By: from the manual

> 0 Distance to the hit polygon of the target or of the next obstacle in the way.
<= 0 No polygon was hit.


A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: How to confirm collision with level blocks? [Re: DLively] #443931
07/28/14 07:24
07/28/14 07:24
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
hi
a little "advertisement" again: in MapBuilder2.41's playertest01 script you can find a proper c-tracing that is used for avoiding collision errors on block borders, which is probably an engine issue. you can get from there the normals you need. (beside some basic walk/run/crouch/fall/shoot features)


Free world editor for 3D Gamestudio: MapBuilder Editor
Re: How to confirm collision with level blocks? [Re: DLively] #443979
07/28/14 15:05
07/28/14 15:05
Joined: Jun 2014
Posts: 97
Lagos, Nigeria
T
tolu619 Offline OP
Junior Member
tolu619  Offline OP
Junior Member
T

Joined: Jun 2014
Posts: 97
Lagos, Nigeria
Originally Posted By: DLively
Code:
var wall;
wall = c_trace(my.x,vec_rotate(vector(100,0,0),my.pan),IGNORE_ME|IGNORE_PASSABLE|IGNORE_CONTENT|IGNORE_MODELS);



The reason this will not work is because you are tracing 100 quants on the x axis, rather than in front of the entity itself.

In order to trace in front of the entity, you will need to use some trig first, and store it inside a VECTOR, and trace from my.x, to the VECTOR you've created.

As old as this AUM is, it covers basic trig to achieve what you will need in order to get the correct direction for your trace.

Also, you can check to see if your trace has hit something, like this:

Code:
result = c_trace(my.x, trace_distance.x, FLAGS);
if(result > 0){beep();}//Hit something



Originally Posted By: from the manual

> 0 Distance to the hit polygon of the target or of the next obstacle in the way.
<= 0 No polygon was hit.


The code in that AUM looks like it would detect even entities. I only want to detect level blocks

Re: How to confirm collision with level blocks? [Re: tolu619] #444006
07/28/14 17:59
07/28/14 17:59
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Please state again exactly what you have tried and what you want to achieve (wallrunning or the like currently is irrelevant, collision with X and ignore Y is the important thing).

This should be implemented with c_trace in player direction (vec_rotate, then vec_add for target position), at least I would not base this on movement collisions. You can use IGNORE_MODELS or whatever the flag is called if you only want to check for block collision.

If you want to save hit-information (~> PM) you can do that with for example a CONTACT struct - however, up until today I've never wanted or needed to do that.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: How to confirm collision with level blocks? [Re: Superku] #444007
07/28/14 18:04
07/28/14 18:04
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline
Serious User
DLively  Offline
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
Quote:
The code in that AUM looks like it would detect even entities. I only want to detect level blocks


Its the Trig I was getting you to look into, and see how to set a vector in front of the entity, using Sin and Cos.


A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: How to confirm collision with level blocks? [Re: DLively] #444014
07/28/14 22:51
07/28/14 22:51
Joined: Jun 2014
Posts: 97
Lagos, Nigeria
T
tolu619 Offline OP
Junior Member
tolu619  Offline OP
Junior Member
T

Joined: Jun 2014
Posts: 97
Lagos, Nigeria
Originally Posted By: DLively
Quote:
The code in that AUM looks like it would detect even entities. I only want to detect level blocks


Its the Trig I was getting you to look into, and see how to set a vector in front of the entity, using Sin and Cos.

Oh, thanks. That's actually quite useful

Page 1 of 2 1 2

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