punch hole in terrain

Posted By: DAVIDMORETON

punch hole in terrain - 04/04/18 10:01

Hi Folks
I need to punch a hole in the middle of a terrain (in Med) so that the player can drop through. - 'delete' will not work - any ideas please?
David.
Posted By: Ezzett

Re: punch hole in terrain - 04/04/18 16:18

Terrains are grid based and you can't "destroy" this grid. I think it should work if you save/convert your terrain as/to a mdl-file. In this case you will lose the polygonal collision detection of the terrain, but you can reactivate exact collision detection for mdl-files via code. But exact collision detection needs more time to compute than terrain based collision detection.
Posted By: DAVIDMORETON

Re: punch hole in terrain - 04/05/18 08:48

Thanks Ezzett - worth giving it a try.
Had another idea - The player travels over the terrain and enters a small tower - when the correct 'oode' is activated, the terrain is made 'passable' - the lift should then drop down through the 'terrain' (and tower floor) with the player - I hope ! will try it and re-post in case anyone else has same problem.
David
Posted By: Quad

Re: punch hole in terrain - 04/05/18 11:13

if it's only a couple of holes, you could split the terrain,or create a transparent parts in the skin and make it passable as you already do.
Posted By: Dooley

Re: punch hole in terrain - 04/05/18 16:56

I use mdl files for all my terrain, which is generated dynamically with tiles. It seems to run okay in-game. But they are small tiles. I don't know how it would work with a very large terrain tile.
Posted By: DAVIDMORETON

Re: punch hole in terrain - 04/12/18 10:47

I have a scene with a terrain, player, and a sphere. The sphere drops to a certain point when the terrain should become passable - BUT IT DOSE NOT!

#include <acknex.h>
#include <default.c>
#include "t_player.h"
//////////////////////////////

ENTITY* player="t_player";

ENTITY* terrain = "tester.hmp";

ENTITY* sphere = "ball.mdl";





function main()
{
level_load("xc1.WMB");

}


action down() //sphere drops to z-16
{

while(sphere.z>-16)
{
sphere=me;
sphere.z -= 3*time_step;
wait(1);
}} //this works fine


{
if(sphere.z<10) //this should be the trigger point //for the 'terrain' to go passable
{
terrain=me;
set(my,PASSABLE);
wait(1);
}} //But it does not work

CAN anyone help please? I need to make the terrain 'passable' or disappear from the scene altogether .
David


Posted By: Realspawn

Re: punch hole in terrain - 04/12/18 13:22

Why not make the sphere passable at that moment laugh

Try changing : set(my,PASSABLE);

into set(terrain,PASSABLE);
Posted By: DAVIDMORETON

Re: punch hole in terrain - 04/12/18 16:29

Thanks for your reply Realspawn - the sphere movement is there only as a trigger point for the terrain 'passable' action - no point in making it passable.
I have tried your suggestion of:-
set(terrain, PASSABLE); ,but the terrain is as solid as ever !!
There must be a way of doing this, but I can't find it.
I have put 'beep' at the end of the action, so I know the engine is working - it's just not recognizing something in the first part of the(terrain part) of the action. Someone must know how to do this ? !!
Hopefully, David
Posted By: Dooley

Re: punch hole in terrain - 04/14/18 06:24

Terrains have certain limitations that models (mdl files) do not. Did you consider making your terrain from an mdl file?
Posted By: DAVIDMORETON

Re: punch hole in terrain - 04/14/18 08:33

Thanks Dooley - have tried that, but it increases the load time somewhat. It's also a mystery (to me) why it won't work.
All I need is for someone to point out where I have gone wrong with my code so that I can learn from it - hopefully .!!
David
Posted By: Kartoffel

Re: punch hole in terrain - 04/14/18 09:17

take a look at your "{" "}"
Edit: nevermind, didn't see that your wrote two different versions of your while loop (I assumed you used the exact code you posted)
Posted By: Dooley

Re: punch hole in terrain - 04/14/18 17:02

I don't think it's your code, I think it might be something inherent to terrains. For instance, according to the manual "Terrain can't be animated, rotated, moved, or scaled." I am thinking that making it passable or not might fall into one of these categories.

Have you tried making a level with just a terrain set to passable, just to see whether the engine can actually handle this?
Posted By: Dooley

Re: punch hole in terrain - 04/14/18 17:04

Another option would be to move your entity directly, like this:

Quote:

var going_down = 0;

While(ent.z > -100)
{
going_down = 1;
ent.z -= 5*time_step;
wait(1);
}

going_down = 0;


This would cause the entity to move down without checking any collision.

If your player entity has a c_move function, it will be checking collision. You could effectively turn this off while it is going down through the terrain by surrounding your c_move with an "if" statement...

Quote:
if(going_down == 0)
{
c_move(ent,move_vec,abs_vec,GLIDE|ETC...) ;
}

Posted By: DAVIDMORETON

Re: punch hole in terrain - 04/15/18 09:38

Hi Dooley,
Thanks for reply.
Terrain will accept 'passable'. If the 'trigger' line
{if(sphere<-10);... is replaced by 'wait-5' - the terrain goes passable and the player drops through.
There must be something wrong or missing in the 'trigger' line
if(sphere etc. That is what I don't understand - logically it should work !!
More Terrains will be used in this game, so I must solve this problem.
Perhaps someone would like to make up a scene (as in my code above) and see if they can make it work? !!
Still hopeful of fixing this !!
David.
Posted By: DAVIDMORETON

Re: punch hole in terrain - 04/17/18 13:56

PROBLEM SOLVED !!
Terrain can be made PASSABLE - also INVISIBLE.
The falling sphere is used just for 'something' to change and trigger the terrain action.
This is the new code - it may help someone (I hope!);-

#include <acknex.h>
#include <default.c>
#include "t_player.h"
//////////////////////////////

ENTITY* player="t_player";

ENTITY* terrain = "tester.hmp";

ENTITY* sphere = "ball.mdl";

function main()
{
level_load("xc1.WMB");

}


action down() //attached to sphere (drops to z-16 to make terrain passable and invisible)
{

while(sphere.z>-16)
{
sphere=me;
sphere.z -= 3*time_step;
wait(1);
}
{
wait(-2); //needed to stop 'judder'
terrain=me;
set(my,INVISIBLE); //needed to stop flash of light as //player drops through terrain
set(terrain,PASSABLE);
}}

Probably not very elegant, but it works. Got it by 'fiddling about' a lot - I felt it should work somehow.
David

NEW - FOUND A BETTER WAY!

remove:-

wait(-2); and set(my,INVISIBLE); and set(terrain,PASSABLE);

then replace with:-

ptr_remove(me);

Much cleaner and it works - hope it helps
David

PS. This is used for player who crosses terrain to tower in middle - enters tower - sets code and drops through to cave system below.


© 2024 lite-C Forums