4 registered members (ozgur, Ayumi, VHX, monarch),
1,161
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
problem understanding c_trace and vec_dist
#313391
03/01/10 09:27
03/01/10 09:27
|
Joined: Dec 2009
Posts: 71
ncc1701d
OP
Junior Member
|
OP
Junior Member
Joined: Dec 2009
Posts: 71
|
newby here can someone take a look at this and tell me what I am doing wrong? I am just trying to use c_trace and vec_dist for the first time. I am trying to display the distance between 2 balls using those 2 types of code tools. thanks
/////////////////////////////// #include <acknex.h> #include <default.c> #include <mtlFX.c>
//////////////////////////////////////////// var distance = 0;//ok ENTITY* ball1; ENTITY* ball2;
PANEL* first_pan = { digits (30, 30, 2, *, 1, distance); flags = VISIBLE; }
function earth() { ball1 = my; my.ambient = 100; c_trace(my.z,ball2.z,USE_BOX); distance = vec_dist(my.z,ball2.z); }
function testball() { ball2 = my; my.ambient = 0; }
function main() { level_load("small.hmp"); ball1 = ent_create("earth.mdl", vector(0, 0, 30), earth); ball2 = ent_create("testball.mdl", vector(0, 0, 65), testball); }
|
|
|
Re: problem understanding c_trace and vec_dist
[Re: ncc1701d]
#313393
03/01/10 09:31
03/01/10 09:31
|
Joined: Jan 2004
Posts: 3,023 The Netherlands
Helghast
Expert
|
Expert
Joined: Jan 2004
Posts: 3,023
The Netherlands
|
you dont need c_trace. only vec_dist will be good enough. vec_dist returns the distance between 2 vectors. c_trace creates a line between 2 points, and checks for collision along the way. if it hit's anything, it will return the distance from the position it traces to the point it hits something. hope I made some sence there. regards, EDIT: after looking more closely at your code, there are several issues. Dont load a .hmp file, create a wmb with WED that you load. also, here is the script fixes I made in your code. now it should work:
///////////////////////////////
#include <acknex.h>
#include <default.c>
#include <mtlFX.c>
////////////////////////////////////////////
var distance = 0;//ok
ENTITY* ball1;
ENTITY* ball2;
PANEL* first_pan =
{
digits (30, 30, 2, *, 1, distance);
flags = VISIBLE;
}
function main()
{
level_load("small.wmb");
wait(5);
ball1 = ent_create("earth.mdl", vector(0, 0, 30), NULL);
ball2 = ent_create("testball.mdl", vector(0, 0, 65), NULL);
distance = vec_dist(ball1.x, ball2.x);
}
If you want to constantly update the distance, put the vec_dist calculation in a loop in your main function.
Last edited by Helghast; 03/01/10 09:35.
|
|
|
Re: problem understanding c_trace and vec_dist
[Re: ncc1701d]
#313551
03/02/10 01:03
03/02/10 01:03
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
AFAIK it's okay to load a hmp (level_load("small.hmp")), not a wmb (this was impossible in prior gamestudio versions, though). I am trying to display the distance between 2 balls using those 2 types of code tools. But now do I have to use c-trace somehow to display the distance from the ball to the the landcape on the floor of the level? Are you dealing with two different problems or is your issue just the first one? In the latter case Helghast's code is fine.
"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
|
|
|
|