Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (TipmyPip, 1 invisible), 18,731 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
scale not affecting physics box #220336
08/07/08 00:39
08/07/08 00:39
Joined: Aug 2008
Posts: 55
United Kingdom
CdeathJD Offline OP
Junior Member
CdeathJD  Offline OP
Junior Member

Joined: Aug 2008
Posts: 55
United Kingdom
Hello there i am trying to get my head around this programming language if thats what it really is... but am quite stuck. I am modifying lesson 19 of the litec workshops pack but have run into a problem.... you will need this file:

http://slcrinkle.googlepages.com/slab.mdl

to be placed in the "workshop19" folder and replace "script19.c" with the code below. (For some reason it MUST have that filename otherwise gives an error... which seems somehow like incredibly bad programming!!!)

I am trying to add a cube type shape to the game and apply physics to it... however scaling the object does not seem to scale the physics, how would this be done? So far i have:
================================================================

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

///////////////////////////////////////////////////////////////

VECTOR ball_speed;
ENTITY* ball;
ENTITY* Slab;

function main()
{
fps_max = 200;
level_load("roller.wmb"); // load the level
wait (2); // wait until the level is loaded
ball = ent_create ("ball.mdl", vector(-400, 0, 100), NULL); // create the ball
ph_setgravity (vector(0, 0, -426)); // set the gravity
phent_settype (ball, PH_RIGID, PH_SPHERE); // set the physics entity type
phent_setmass (ball, 3, PH_SPHERE); // and its mass
phent_setfriction (ball, 199); // set the friction
phent_setdamping (ball, 20, 20); // set the damping
phent_setelasticity (ball, 20, 5); // set the elasticity
Slab = ent_create ("Slab.mdl", vector(-400, 0, 100), NULL); // create the ball
phent_settype (Slab, PH_RIGID, PH_BOX); // set the physics entity type
phent_setmass (Slab, 3, PH_BOX); // and its mass
phent_setfriction (Slab, 199); // set the friction
phent_setdamping (Slab, 20, 20); // set the damping
phent_setelasticity (Slab, 20, 5); // set the elasticity
Slab.scale_x = 5;
Slab.scale_y = 15;
Slab.scale_z = 5;

while (1)
{
ball_speed.x = 35 * (key_cur - key_cul); // move the ball using the cursor keys
ball_speed.y = 35 * (key_cuu - key_cud); // 25 sets the x / y movement speeds
ball_speed.z = 0; // no need to move on the vertical axis
phent_addtorqueglobal (ball, ball_speed); // add a torque (an angular force) to the ball
camera.x = ball.x - 400; // keep the camera 300 quants behind the ball
camera.y = ball.y; // using the same y with the ball
camera.z = ball.z + 100; // and place it at z = 1000 quants

camera.tilt = -5; // make it look downwards
wait (1);
}
}

=============================================================

I have tried changing "settype" and "setmass" to PH_POLY also, but this just made the object fall through the floor once settled on the ground... which is bad physics really.

Any help is appreciated!


I am a noob to this... Blitz3D is where i am best at!
Re: scale not affecting physics box [Re: CdeathJD] #220337
08/07/08 00:45
08/07/08 00:45
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
not 100 sure but try

Code:
wait(1);
c_setminmax(ball); 


Re: scale not affecting physics box [Re: MrGuest] #220339
08/07/08 01:06
08/07/08 01:06
Joined: Aug 2008
Posts: 55
United Kingdom
CdeathJD Offline OP
Junior Member
CdeathJD  Offline OP
Junior Member

Joined: Aug 2008
Posts: 55
United Kingdom
i tried putting that after the scale commands (or where you meant im not sure). But the ball still rolls through the cube till it gets to the middle and then bumps over it :s


I am a noob to this... Blitz3D is where i am best at!
Re: scale not affecting physics box [Re: CdeathJD] #220416
08/07/08 10:27
08/07/08 10:27
Joined: Nov 2007
Posts: 1,032
Croatia
croman Offline
Serious User
croman  Offline
Serious User

Joined: Nov 2007
Posts: 1,032
Croatia
you cant scale or move or rotate physics oject . you need to disable physics for that object scale it, apply c_setminmax(me) again and then reenable physics. for disabling and enabling physics use phent_settype()



Ubi bene, ibi Patria.
Re: scale not affecting physics box [Re: croman] #220427
08/07/08 11:02
08/07/08 11:02
Joined: Sep 2007
Posts: 761
Hrvatska (Croatia ), Slavonski...
cro_games Offline
User
cro_games  Offline
User

Joined: Sep 2007
Posts: 761
Hrvatska (Croatia ), Slavonski...
Originally Posted By: cerberi_croman
...for disabling and enabling physics use phent_settype()

No..Use "phent_enable(my,0);" to turn off physics, and "phent_enable(my,1);" to turn them back on..

Last edited by cro_games; 08/07/08 11:06.

Hello everyone my name is Ivan Mandic from "Frozen pixel studio". wink
-----------------------------------
Homepage: www.fpx-studio.com
e-mail: emu_hunter_1990@hotmail.com
(working on a game engine)
Re: scale not affecting physics box [Re: croman] #220428
08/07/08 11:02
08/07/08 11:02
Joined: Aug 2008
Posts: 55
United Kingdom
CdeathJD Offline OP
Junior Member
CdeathJD  Offline OP
Junior Member

Joined: Aug 2008
Posts: 55
United Kingdom
Roger.... disabling physics worked!

Strange though... i couldn't scale the object before i applied physics, which would have taken less lines... i had to apply physics-disable them-scale the object- then turn on physics again which seems like a bit of a run around!

Either way im now trying to make one object "Look at" another... without much success too :|


I am a noob to this... Blitz3D is where i am best at!
Re: scale not affecting physics box [Re: CdeathJD] #220429
08/07/08 11:04
08/07/08 11:04
Joined: Nov 2007
Posts: 1,032
Croatia
croman Offline
Serious User
croman  Offline
Serious User

Joined: Nov 2007
Posts: 1,032
Croatia
yeah you can use that too, i totally forgot about that hehe



Ubi bene, ibi Patria.
Re: scale not affecting physics box [Re: CdeathJD] #220430
08/07/08 11:11
08/07/08 11:11
Joined: Sep 2007
Posts: 761
Hrvatska (Croatia ), Slavonski...
cro_games Offline
User
cro_games  Offline
User

Joined: Sep 2007
Posts: 761
Hrvatska (Croatia ), Slavonski...
Originally Posted By: CdeathJD

Either way im now trying to make one object "Look at" another... without much success too :|


Object1 is looking object2:
vec_set(temp, object2_ent);
vec_sub(temp, object1_ent);
vec_to_angle(object1_ent.pan, temp);

p.s.
ent = entity,not action/function name..


Last edited by cro_games; 08/07/08 11:12.

Hello everyone my name is Ivan Mandic from "Frozen pixel studio". wink
-----------------------------------
Homepage: www.fpx-studio.com
e-mail: emu_hunter_1990@hotmail.com
(working on a game engine)
Re: scale not affecting physics box [Re: cro_games] #220431
08/07/08 11:16
08/07/08 11:16
Joined: Aug 2008
Posts: 55
United Kingdom
CdeathJD Offline OP
Junior Member
CdeathJD  Offline OP
Junior Member

Joined: Aug 2008
Posts: 55
United Kingdom
Exactly what i've just tried sir! I adapted it for the program like so:

vec_set(Temp,ball);
vec_sub(Temp,camera);
vec_to_angle( camera.pan ,Temp); // now MY looks at YOU

And placed it in my main loop (i want it to be updated each frame), but it only runs the first time :S I'm guessing i need to make the program go "Oh its over there now!" if i move the ball?


I am a noob to this... Blitz3D is where i am best at!
Re: scale not affecting physics box [Re: CdeathJD] #220450
08/07/08 11:22
08/07/08 11:22
Joined: Nov 2007
Posts: 1,032
Croatia
croman Offline
Serious User
croman  Offline
Serious User

Joined: Nov 2007
Posts: 1,032
Croatia
can i see that part of your code? that main loop



Ubi bene, ibi Patria.
Page 1 of 3 1 2 3

Gamestudio download | 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