Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (Joey, flink, AndrewAMD), 1,226 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Forces from beyond the grave.... o my god!!! #24086
03/12/04 01:27
03/12/04 01:27
Joined: Mar 2002
Posts: 60
São Paulo, Brazil
L
Lord Alexion Offline OP
Junior Member
Lord Alexion  Offline OP
Junior Member
L

Joined: Mar 2002
Posts: 60
São Paulo, Brazil
Well, guys, I'm having a bit of a problem here. I have this ball model on my map, which I'm using as an anchor for the camera object. I wanted the camera to move in a smooth and realistic manner, so I have set the ball as a physics entity, and put a while(1) inside the entity action that moves the camera to a constant position relative to the ball.

but I'm getting this nasty error where when I enable the physics engine for the ball, a force is applied to it in a up-right direction. I didn't put ANY force in the ball, yet it moves by itself. I really don't understand, it's like some ghosts pushed the ball...

look at the ball's action, maybe you guys can figure out this mystery...

Code:
action handle_sphere() {


my.scale_x = 0.2;
my.scale_y = 0.2;
my.scale_z = 0.2;

var earthgravity[3] = 0,0, -386;

phent_settype(my, PH_RIGID, PH_SPHERE);
phent_setfriction(my,100);
phent_setmass (my, 25, PH_SPHERE);
//phent_setdamping(my,50,0);
phent_setgroup(my,1);
phent_setelasticity (my, 100, 100);
phent_enable(my, 1);
//ph_setgravity(earthgravity);


my.transparent = on;
my.alpha = 65;

focus_x = my.x;
focus_y = my.y;
focus_z = my.z;

var s_temp[3];

while (1) {

vec_set(s_temp,vector(120,-120,110));
vec_add(s_temp,my.x);
vec_set(camera.x,s_temp);

vec_set(s_temp,my.x);
vec_sub(s_temp,camera.x);
vec_to_angle (camera.pan,s_temp);

wait(1);
}
}



By the way, the damping and gravity setting instructions are commented because I wanted to figure out the actual force being applied to the ball. Commenting those lines, the ball flies up and to the right forever. Without commenting those lines the ball rolls to the right de-accelerating until it stops. it's really strange, because I DIDN'T APPLY any force to the ball. thanks in advance

EDIT: I got some more info by putting some strategic watches and phent_getvelocity instructions:

1-) the mysterious force is applied to the ball 2 frame cycles after the phent_settype instruction

2-) the force applied to the ball is given by the vector (149.63,0,55.12)

3-) it appears that some torque is applied to the ball also. If the ball hits the map's skybox, it bounces off rolling a bit, and I also got differences in the velocity when I set phent_setmaxspeed to (1000,0.00001). I got these velocities from point 0,0,0.

Last edited by Lord Alexion; 03/12/04 01:51.
Re: Forces from beyond the grave.... o my god!!! [Re: Lord Alexion] #24087
03/12/04 02:10
03/12/04 02:10
Joined: Mar 2003
Posts: 5,377
USofA
fastlane69 Offline
Senior Expert
fastlane69  Offline
Senior Expert

Joined: Mar 2003
Posts: 5,377
USofA
Let try simple solutions first:

1) Are you starting your entity at least 100 quants above the ground? If your entity starts with even one quant into the ground, once the PE engages, it will apply a force much like you described.

2) Turn gravity back on. If the ball comes back to the ground, bounces (turn elasticity to less than 100 so it it's bounce will die) and comes to a halt (since you have friction) normally, then your problem is with ent init. otherwise, it's something in your main code.

3) Since 3DGS has no inbuild force function, how did you come up with
Quote:

the force applied to the ball is given by the vector (149.63,0,55.12)






Re: Forces from beyond the grave.... o my god!!! [Re: fastlane69] #24088
03/12/04 02:36
03/12/04 02:36
Joined: Mar 2002
Posts: 60
São Paulo, Brazil
L
Lord Alexion Offline OP
Junior Member
Lord Alexion  Offline OP
Junior Member
L

Joined: Mar 2002
Posts: 60
São Paulo, Brazil
1-) I started my entity 16 quants abobve the ground. I fixed that to 100 quants, and the problem was solved but... if I do the "disable, change position, enable" routine, the problem get's back! does that mean the only way of getting my entity on the ground is to make it fall from 100 quants???

2-) yes, it happened as you described. the ball acts completely normal, 100 quants from the ground or not, with the difference only being this freaky force applied.

3-) well, now that I thought about it, maybe the instant velocity of the moment the force is applied is NOT equal to the force vector...

EDIT: did some experimenting... but now it came to another issue: I need this physics entity to pass throught the passable sprites in my level, but it doesn't. I use a 2d sprite as a character, and no matter what I do, the ball always bounces on his head, but it should bounce on the ground. any ideas?

EDIT2: forget about the last edit, I was just setting the passable flag to the wrong entity ^^o

Last edited by Lord Alexion; 03/12/04 02:55.
Re: Forces from beyond the grave.... o my god!!! [Re: Lord Alexion] #24089
03/12/04 03:02
03/12/04 03:02
Joined: Mar 2003
Posts: 5,377
USofA
fastlane69 Offline
Senior Expert
fastlane69  Offline
Senior Expert

Joined: Mar 2003
Posts: 5,377
USofA
Quote:

3-) well, now that I thought about it, maybe the instant velocity of the moment the force is applied is NOT equal to the force vector...




Lord have mercy, I can't tell you how many times I have heard my students say exactly the same thing after a test or homework is due!! LOL

Quote:

1-) I started my entity 16 quants abobve the ground. I fixed that to 100 quants, and the problem was solved but... if I do the "disable, change position, enable" routine, the problem get's back! does that mean the only way of getting my entity on the ground is to make it fall from 100 quants???

2-) yes, it happened as you described. the ball acts completely normal, 100 quants from the ground or not, with the difference only being this freaky force applied.





I wouldn't mess with disable. As we only recently found out, phent_disable only PAUSES an entity. This means when you re enable, it will start with the same physical parameters as it had before you paused (ie...freaky forces).

Rather, as JCL has told us, use the phent_settype command to UNREGISTER the entity. Then when you re-register, their physical parameters *should* be cleared and no more freaky forces.


Re: Forces from beyond the grave.... o my god!!! [Re: fastlane69] #24090
03/12/04 03:58
03/12/04 03:58
Joined: Mar 2002
Posts: 60
São Paulo, Brazil
L
Lord Alexion Offline OP
Junior Member
Lord Alexion  Offline OP
Junior Member
L

Joined: Mar 2002
Posts: 60
São Paulo, Brazil
I kinda fixed the problem, but another one came up: you see, as I told you before, the physical entity is a ball that only acts as a gizmo to position/rotate the camera. let me add here a little screenshot of my work up-to-now (the char is a ripped "Final Fantasy Tactics" sprite which I'm using to test the code before the artist in my team starts sending stuff), in here:

(seems like I can't print-screen anything while the engine is running, it messes up all the colors, does anybody knows why this happens? I'll post a screenshot here when it is finished...)

Meanwhile, I'll try to explain it here: it's an isometric view, always focused in the active "tile". all maps are composed of tiles, which are 32x32x16 quants in size. The player needs to be able to select a tile, and the camera will smoothly fly on it's direction, de-acelerating in the process. this camera will also follow characters when they are moving. All movement, cursor or character, will be tile-by-tile, but the actual motion will be smooth and realistic.

So, that's why I have this gizmo. it'll be invisible, of course, but I'm leaving it on now so I can see the processes better. the camera is permanently attached to the gizmo, so, all I have to do to move the camera is make the gizmo move. And moving the gizmo by applying forces to it makes the process esier to code AND smoother/more realistic.

my error before was that I forgot, the character sprites should be PASSABLE. really often the gizmo will need to overlap a sprite to indicate the camera to focus on the character, and I forgot to set this option. the gizmo was inside the character, and that's why the "freaky forces" event happened. It was fixed when I set passable = on in the character entity.

now I have another problem: is it possible to make the gizmo a ghost? I mean, able to fly through all the map's walls and entities?

Re: Forces from beyond the grave.... o my god!!! [Re: Lord Alexion] #24091
03/12/04 04:40
03/12/04 04:40
Joined: Mar 2003
Posts: 5,377
USofA
fastlane69 Offline
Senior Expert
fastlane69  Offline
Senior Expert

Joined: Mar 2003
Posts: 5,377
USofA
Quote:

is it possible to make the gizmo a ghost? I mean, able to fly through all the map's walls and entities?





Why isn't passable accomplishing this alredy?


Re: Forces from beyond the grave.... o my god!!! [Re: fastlane69] #24092
03/12/04 04:43
03/12/04 04:43
Joined: Mar 2002
Posts: 60
São Paulo, Brazil
L
Lord Alexion Offline OP
Junior Member
Lord Alexion  Offline OP
Junior Member
L

Joined: Mar 2002
Posts: 60
São Paulo, Brazil
beats me. Anyway, I just figured out I can do an easier and better effect by making the entity NOT be a physics entity. but thanks a lot you guys, I sure learned a lot of the physics engine in this thread. I'm inclined to use this for character movement....

Re: Forces from beyond the grave.... o my god!!! [Re: Lord Alexion] #24093
03/12/04 04:51
03/12/04 04:51
Joined: Mar 2003
Posts: 5,377
USofA
fastlane69 Offline
Senior Expert
fastlane69  Offline
Senior Expert

Joined: Mar 2003
Posts: 5,377
USofA
Quote:

I sure learned a lot of the physics engine in this thread. I'm inclined to use this for character movement....




Proper!
GL!


Moderated by  HeelX, Spirit 

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