2 registered members (AndrewAMD, TipmyPip),
12,420
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
A Problem of using physics system
#189216
03/18/08 14:58
03/18/08 14:58
|
Joined: Nov 2007
Posts: 37
LavenderSs
OP
Newbie
|
OP
Newbie
Joined: Nov 2007
Posts: 37
|
Hi ,guys. I want to add physics system to a character to make it move as a real person and use some 'ph_/phent_' commands in the lite-c script. But when running the code the model could do nothing but perform the 'walk' animation in the original place. The code is like this:
action walking_guard() { guard = my; guard.material = mat_model; phent_settype(guard,PH_RIGID,PH_SPHERE); phent_setmass(guard,3,PH_SPHERE); phent_setfriction(guard,80);
phent_setelasticity(guard,40,40); phent_setdamping(guard,30,5); ph_setgravity(vector(0,0,-386));
while(1) { if(key_w == 0 && key_s == 0 && key_e == 0) { ent_animate(my,"stand",walk_percentage, ANM_CYCLE); walk_percentage += 3 * time_step; } else { if(key_e == 0) { ent_animate(my,"walk",walk_percentage, ANM_CYCLE); walk_percentage += 5 * time_step; } } } } Many thanks!!
|
|
|
Re: A Problem of using physics system
[Re: LavenderSs]
#189217
03/18/08 16:21
03/18/08 16:21
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
Well, what are you supposing the entity to do, other than playing it's walk animation? Did you try letting another object collide with the entity?
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: A Problem of using physics system
[Re: LavenderSs]
#189219
03/19/08 04:43
03/19/08 04:43
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
Did you apply any force to the object? The above shown code won't let your entity move, it will just animate it.
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: A Problem of using physics system
[Re: Uhrwerk]
#189220
03/19/08 21:53
03/19/08 21:53
|
Joined: Mar 2007
Posts: 677 0x00000USA
MrCode
User
|
User
Joined: Mar 2007
Posts: 677
0x00000USA
|
Yes, you will need to put some phent_addcentralforce() calls (or something similar) somewhere in your while loop to enable your entity to move. But how is your entity going to keep it's balance? How tall is it compared to it's width or length? If it's taller than it is wide and/or long, then you'll need to find some way to keep your entity standing. Maybe you could apply your forces to the bottom of your entity via phent_addvellocal(), thereby minimizing the problem of keeping your entity standing. Of course, you could just ignore what I said above if it doesn't apply to your case. 
void main()
{
cout << "I am MrCode,";
cout << "hear me roar!";
system("PAUSE");
}
|
|
|
|