1 registered members (AndrewAMD),
742
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Water block not beeping
#452908
06/30/15 06:49
06/30/15 06:49
|
Joined: Jun 2010
Posts: 590 California
Ruben
OP
User
|
OP
User
Joined: Jun 2010
Posts: 590
California
|
I am trying to create swimming/buoyancy functionality in my game. I created a block in a castle moat that represents water. If the player jumps into the block, I want the player to start swimming. However, I am at the very beginning stages of trying to make this happen. Right now, I am just trying to make my player "sense" the passable and transparent block, by sounding a beep() when the player makes contact with it. So far, the beep() is not sounding when the player jumps into and makes contact with the block. The block is saved as a map entity in its own WED file. Here is the code to try to make the beep() sound when the player makes contact with the block:
action moatSide1()
{
moat_side_one = me;
}
...
player_code()
{
...
while(my.x)
{
...
if(you == moat_side_one)
{
beep();
}
...
wait(1)
}
}
The moat block is given the behaviour action of "moatSide1" in WED, and the player is given the behaviour action of "player_code". Yet when the player jumps in the block, and player passes through it since it is passable, no beep() is sounded off. Does anyone know why?
Last edited by Ruben; 06/30/15 06:49.
|
|
|
Re: Water block not beeping
[Re: Ruben]
#452911
06/30/15 09:07
06/30/15 09:07
|
Joined: Dec 2011
Posts: 1,823 Netherlands
Reconnoiter
Serious User
|
Serious User
Joined: Dec 2011
Posts: 1,823
Netherlands
|
It looks like you forgot to copy the vital parts of the code here in your post. But anyway, what you wanna do is just trace below the player and check the texture (there are possible more alternatives but this works fine). First you need to go to your block and change the texture name of it in MED or whatever to e.g. water_tex or something else suiting, than use this code:
if (every_blabla_frame_this_reduces_fps) //optionally
{
if (c_trace(my.x, vector(my.x, my.y, my.z - 1000), IGNORE_CONTENT | IGNORE_ME | SCAN_TEXTURE) > 0)
{
if (str_cmpi(hit.texname, "water_tex") == 1)
{
//do your thing
}
}
}
Last edited by Reconnoiter; 06/30/15 09:08.
|
|
|
Re: Water block not beeping
[Re: Reconnoiter]
#452912
06/30/15 09:59
06/30/15 09:59
|
Joined: Jun 2010
Posts: 590 California
Ruben
OP
User
|
OP
User
Joined: Jun 2010
Posts: 590
California
|
I tried placing your code in my player_code() function, and inside the while() loop, as follows:
if (c_trace(my.x, vector(my.x, my.y, my.z - 1000), IGNORE_CONTENT | IGNORE_ME | SCAN_TEXTURE) > 0)
{
//if (str_cmpi(hit.texname, "MoatSide1_wmb_734") == 1)
//if (str_cmpi(hit.texname, "water2") == 1)
if (str_cmpi(hit.texname, "MoatSide1") == 1)
{
beep();
}
}
The name of the block after being imported into a castle WED file as a map entity from its own WED file is "MoatSide1_wmb_734". The name of this same block sitting in its own WED file is "MoatSide1". The name of the texture on this same block is "*water2", taken straight from standard.wad. Yet none of these are producing the beep(). Am I doing something wrong to make this happen?
Last edited by Ruben; 06/30/15 10:01.
|
|
|
Re: Water block not beeping
[Re: Ruben]
#452915
06/30/15 12:45
06/30/15 12:45
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
User
|
User
Joined: Mar 2012
Posts: 927
cyberspace
|
what is while (my.x) ?
anyway , just use a region or the min max size to determine if the player has entered the area .
without the actual code which you use to detect whether the player is inside the water ,plus how you set up that events (I am assuming) no one will know WHY what's happening.
we don't even know if your windows system sounds has a sound assigned to the relevant beep (I dont know if GS has its own but usually its taken from system sounds) , I assume there's nothing wrong with the sound aspect as is normal but you really need to provide the relevant code , for people to help you .
Compulsive compiler
|
|
|
Re: Water block not beeping
[Re: Reconnoiter]
#452941
07/01/15 05:28
07/01/15 05:28
|
Joined: Jun 2010
Posts: 590 California
Ruben
OP
User
|
OP
User
Joined: Jun 2010
Posts: 590
California
|
@Ruben, try a beep/error() before the c_trace, and see if that works.
I put a beep before the c_trace, and I am definitely hearing a bunch of beeps over and over. However, the c_trace is not catching anything to initiate its own beep. Here is the code I tried:
...
action player_code()
{
...
while(1)
{
...
//beep(); // DEFINITELY IS SOUNDING OFF WHEN UNCOMMENTED.
if (c_trace(my.x, vector(my.x, my.y, my.z - 1000), IGNORE_ME | SCAN_TEXTURE) > 0)
{
if (str_cmpi(hit.texname, "*water2") == 1)
{
beep();
}
}
...
wait(1);
}
}
I am using the texture from standard.wad titled *water2 for the water block in question. Does anyone know why the beep() sounds before the c_trace(), but not in the c_trace()?
Last edited by Ruben; 07/01/15 05:30.
|
|
|
Re: Water block not beeping
[Re: Reconnoiter]
#452946
07/01/15 11:42
07/01/15 11:42
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
User
|
User
Joined: Mar 2012
Posts: 927
cyberspace
|
okay so i did a little test , i created a block ,set it passable , applied a texture "grey" to it then i assigned the test action script to a object (dont have time to create a player) and used the camera to trace from. now here comes the catch with that c_trace approach , the trace hits the surface and when the surface is hit , the tex name is retrieved , if you are inside of the block there will be NO HIT and it wil not help . like i suggested , use a region or min max sizes ,so that you can detect when the player ,like its center point or something is INSIDE the area ,or whatever other event detection /code/flags stuff you think up . here is the code i used to test it , now fly around and see for yourseld that , the trace will work only when you are above the surface of the block because i you are tracing down against the surface here
#include <acknex.h>
#include <default.c>
action test()
{
while(1)
{
if(c_trace(camera.x,vector(camera.x,camera.y,camera.z-1000),IGNORE_ME | SCAN_TEXTURE))
{
if(str_cmpi(hit.texname,"grey"))
{
DEBUG_VAR(1,100);
}
else DEBUG_VAR(0,100);
}
wait(1);
}
}
function main()
{
warn_level = 4;
def_move();
level_load("1.wmb");
}
for example try a c_intersect approach
Last edited by Wjbender; 07/01/15 11:47.
Compulsive compiler
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|