Gamestudio Links
Zorro Links
Newest Posts
Why Zorro supports up to 72 cores?
by 11honza11. 04/26/24 08:55
M1 Oversampling
by 11honza11. 04/26/24 08:32
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, VoroneTZ, Quad, 1 invisible), 837 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
hinge physics- making it stay #34713
10/09/04 15:32
10/09/04 15:32
Joined: Jul 2003
Posts: 1,300
Albury, Australia
James_Burke Offline OP
Serious User
James_Burke  Offline OP
Serious User

Joined: Jul 2003
Posts: 1,300
Albury, Australia
Hi,
I'm don't know anything much about physics. So you'll have to excuse my noobiness when it comes to physics

I've been adapting the code from 3PM Feb, and here's what I have:
Code:
  
//-----------------------------
//Variable Defines
//-----------------------------
//Temp physic variables
var h_id;
var p2[3];
var p3[3];
var p4[3];
var p5[3];
var p6[3];
var door_max[3];

//-----------------------------
//Pointer Defines
//-----------------------------
entity* hinge; //Hinge pointer

//-----------------------------
//Actions
//-----------------------------
//---------------
//Desc: Hindge which connects the door
//---------------
action hinge_ent
{
hinge = my; //Give it the hinge pointer
my.passable = on; //Passable
wait(1);
}

//---------------
//Desc: A standard door
//---------------
action door
{
while(player == null)
{
wait(1); //Prevents empty pointers
}
phent_settype(my, ph_rigid, ph_box); //Is a physics object
phent_setgroup(my, 2);
phent_setmass(my, 100, ph_box);
phent_setfriction(my, 10);
phent_setelasticity(my, 2, 1);

//Sets the parameter vectors
vec_set(p2, vector(0, 0, 1));
vec_set(p3, vector(0, 0, 0));
vec_set(p4, vector(-90, 90, 0));
vec_set(p6, vector(0, 0, 0));

h_id = phcon_add(ph_hinge, my, hinge); ///Enables a 'hinge' joint

//Set the parameters
phcon_setparams1(h_id, hinge.x, p2, nullvector);
phcon_setparams2(h_id, p4, nullvector, nullvector);

//Set the speed
vec_set(door_max, vector(20, 10, 0));
phcon_setmotor(h_id, door_max, nullvector, nullvector);
}



Now, the problem is the door keeps going away from the hinge, which it shouldn't do. Have I missed something?
Here's a pic of it set up in WED incase there's a problem with that:


And here's the result:


Thanks for any help,
James

Re: hinge physics- making it stay [Re: James_Burke] #34714
10/09/04 16:58
10/09/04 16:58
Joined: Aug 2001
Posts: 2,320
Alberta, Canada
William Offline
Expert
William  Offline
Expert

Joined: Aug 2001
Posts: 2,320
Alberta, Canada
I tested the code that you posted with my models from the 3PM article. It worked fine for me... You should change this line so it works better(you must have typed it wrong):
What you had:
h_id = phcon_add(ph_hinge, my, hinge);

Change To:
h_id = phcon_add(ph_hinge, my, 0);

The reason for this is that you are not needing to set up 2 contraints with ph_hinge. Ph_wheel for an example, requires two contraints(the wheel, and the body), but with a hinge constraint you only need one which would be the door entity.

I doubt changing that line will fix it for you, it is most likley an origin problem with your models. Are you origins set right in MED? The origins of the models in MED is where the two objects connect via the constraint, if these are set wrong then you will experience very weird behaviour since it will be rotating itself around the messed up origin. As you may know, "my.x" is the origin of the entity in MED. Since the anchor point of the door entity is "hinge.x", your door model will swivel around the origin of the hinge model. Load up the models that I used in 3PM and look at how I set up the origins and duplicate it for your models.


Check out Silas. www.kartsilas.com

Hear my band Finding Fire - www.myspace.com/findingfire

Daily dev updates - http://kartsilas.blogspot.com/
Re: hinge physics- making it stay [Re: William] #34715
10/09/04 18:13
10/09/04 18:13
Joined: Jul 2003
Posts: 1,300
Albury, Australia
James_Burke Offline OP
Serious User
James_Burke  Offline OP
Serious User

Joined: Jul 2003
Posts: 1,300
Albury, Australia
Thanks,
That worked, but now for some reason, I can go one way ok, but I can't go back. Any advice there?
Thanks again,
James

Re: hinge physics- making it stay [Re: James_Burke] #34716
10/10/04 05:01
10/10/04 05:01
Joined: Aug 2001
Posts: 2,320
Alberta, Canada
William Offline
Expert
William  Offline
Expert

Joined: Aug 2001
Posts: 2,320
Alberta, Canada
Its going both ways for me. I'm not exactly sure what your problem there would be. Though, I have noticed that it can tend to get slightly stuck in the wall if you hit it hard enough and keep on pushing it into the wall. Try fiddling with the amount you have set for the contraints motor.


Check out Silas. www.kartsilas.com

Hear my band Finding Fire - www.myspace.com/findingfire

Daily dev updates - http://kartsilas.blogspot.com/
Re: hinge physics- making it stay [Re: William] #34717
10/10/04 07:40
10/10/04 07:40
Joined: Jul 2003
Posts: 1,300
Albury, Australia
James_Burke Offline OP
Serious User
James_Burke  Offline OP
Serious User

Joined: Jul 2003
Posts: 1,300
Albury, Australia
Thanks, that's proberly the problem


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