|
[newton] ent_move command???
#49624
07/20/05 16:55
07/20/05 16:55
|
Joined: Aug 2004
Posts: 593 Germany
Efrint
OP
Developer
|
OP
Developer
Joined: Aug 2004
Posts: 593
Germany
|
Hallo, i tried to do a script for a player. Is there a command in newton like ent_move? If i use newton in the player-function, the A6 collision-detction doesn´t work anymore. So, if i use c_move or ent_move, the player falls just through the floor. Please take a look at my script and tell me, how i could implement the moving, while pressing the cursor buttons. Code:
ACTION pod { player=my; score.visible=on; my.event=fall_event; newtoncreategravityentity(wood_material); while(1) { ////camera//// update_views(); camera_to_target(); ////walking//// ent_cycle("core", my.skill48 % 100); my.skill48 += 8 * time; c_move (me,laufen,nullvector,GLIDE+IGNORE_PASSABLE); c_move (me,unten,nullvector,IGNORE_PASSABLE); ////controle//// if (key_cuu==1) { laufen=1; ent_cycle("run", my.skill48 % 100);
} else { laufen=0; } if (key_cud==1) { laufen=-1; } if (key_cul==1) { my.pan+=5*time; } if (key_cur==1) { my.pan-=5*time; } wait(1); } }
} I hope, you can help me.... Regards Efrint
|
|
|
Re: [newton] ent_move command???
[Re: Marcio Esper]
#49626
07/21/05 13:26
07/21/05 13:26
|
Joined: Aug 2004
Posts: 593 Germany
Efrint
OP
Developer
|
OP
Developer
Joined: Aug 2004
Posts: 593
Germany
|
now i did this....i don´t know, if it is that, what you meant.....it doesn´t work...the player stays at his place and doesn´t fall down..... Code:
ACTION pod { player=my; var pod; score.visible=on; my.event=fall_event; newtoncreategravityentity(wood_material); pod= NewtonGetBody (my); NewtonSetBodyActiveState (pod,1); while(1) { ////camera//// update_views(); camera_to_target(); ////walking//// ent_cycle("core", my.skill48 % 100); // wiederhole die Animation endlos my.skill48 += 8 * time; ////controle//// if (key_cuu==1) { laufen=1; ent_cycle("run", my.skill48 % 100);
} else { laufen=0; } if (key_cud==1) { laufen=-1; } if (key_cul==1) { my.pan+=5*time; } if (key_cur==1) { my.pan-=5*time; } wait(1); } }
} why doesn´t that work? Regards Efrint
|
|
|
Re: [newton] ent_move command???
[Re: Efrint]
#49627
07/21/05 14:09
07/21/05 14:09
|
Joined: Sep 2002
Posts: 344 São Paulo SP Brazil
Marcio Esper
Senior Member
|
Senior Member
Joined: Sep 2002
Posts: 344
São Paulo SP Brazil
|
try put this function and change in the start of your code if you get a error, double definition or some thing like this, look if you do not have include this in your main script includes like newtinScript2.wdl if yes, just delet the defines lines and function. Code:
define newtonGravity, -700.0; define mass, skill1; // you need set this in your behaviors entity window define linear_drag, skill2; define angular_drag_x, skill3; define angular_drag_y, skill4; define angular_drag_z, skill5; define health, skill6; define shape_factor, skill7; define collision_groupId, skill8; define collision_sph_box, flag1; define start_active, flag2; define compound_collision, flag3; define destructible, flag4; define spawn_children, flag5;
function ApplyGravityForceEvent(body) { var bodyMass; bodyMass = NewtonGetBodyMass (body); NewtonBodyAddForce (body, 0, 0, bodyMass * newtonGravity); NewtonBodyAddTorque (body, 0, 0, 0);//
// apply buoyancy force to the boby if any ApplyBuoyancy (body); wait(1); // For not use so much CPU you can encrese this but you // get a delay in action }
ACTION pod { player=my; score.visible=on; NewtonGetBody (my); newtoncreategravityentity(wood_material); NewtonSetBodyActiveState (body,1); while(1) { ApplyGravityForceEvent(my) ////camera//// update_views(); camera_to_target(); ////walking//// ent_cycle("core", my.skill48 % 100); // wiederhole die Animation endlos my.skill48 += 8 * time; ////controle//// if (key_cuu==1) { laufen=1; ent_cycle("run", my.skill48 % 100);
} else { laufen=0; } if (key_cud==1) { laufen=-1; } if (key_cul==1) { my.pan+=5*time; } if (key_cur==1) { my.pan-=5*time; } wait(1); } }
}
I hope it help you. Tel me if it works. best regards, Marcio
|
|
|
Re: [newton] ent_move command???
[Re: Marcio Esper]
#49628
07/21/05 16:42
07/21/05 16:42
|
Joined: Aug 2004
Posts: 593 Germany
Efrint
OP
Developer
|
OP
Developer
Joined: Aug 2004
Posts: 593
Germany
|
i get an error: crash in NewtonSetBodyActiveState and you forgot a semicolon....but the rest seems to be ok....how can i solve the error? At the moment nothing works because of the error.... Regards Efrint
|
|
|
Re: [newton] ent_move command???
[Re: Marcio Esper]
#49630
07/22/05 11:31
07/22/05 11:31
|
Joined: Aug 2004
Posts: 593 Germany
Efrint
OP
Developer
|
OP
Developer
Joined: Aug 2004
Posts: 593
Germany
|
ok....it doesn´t work....i noticed, that newton crashes in almost every command. I commented ou every command, that crashes. Code:
define newtonGravity, -700.0; define mass, skill1; // you need set this in your behaviors entity window define linear_drag, skill2; define angular_drag_x, skill3; define angular_drag_y, skill4; define angular_drag_z, skill5; define health, skill6; define shape_factor, skill7; define collision_groupId, skill8; define collision_sph_box, flag1; define start_active, flag2; define compound_collision, flag3; define destructible, flag4; define spawn_children, flag5;
function ApplyGravityForceEvent(body) { var bodyMass; //bodyMass = NewtonGetBodyMass (body); //NewtonBodyAddForce (body, 0, 0, bodyMass * newtonGravity); //NewtonBodyAddTorque (body, 0, 0, 0);//
// apply buoyancy force to the boby if any ApplyBuoyancy (body); wait(1); // For not use so much CPU you can encrese this but you // get a delay in action }
ACTION pod { player=my; score.visible=on; NewtonGetBody (my); newtoncreategravityentity(wood_material); //NewtonSetBodyAutoActiveState (body, 0); //use this before , it turn off the auto activate //NewtonSetBodyActiveState (body, 1);
while(1) { ApplyGravityForceEvent(my); ////camera//// update_views(); camera_to_target(); ////walking//// ent_cycle("core", my.skill48 % 100); // wiederhole die Animation endlos my.skill48 += 8 * time; ////controle//// if (key_cuu==1) { laufen=1; ent_cycle("run", my.skill48 % 100);
} else { laufen=0; } if (key_cud==1) { laufen=-1; } if (key_cul==1) { my.pan+=5*time; } if (key_cur==1) { my.pan-=5*time; } wait(1); } }
} everything, that crashes is commented out with //. But even now, i receive the error: crash in newtonsetbodyautoactivestate but that is commented out! Why does it crash? Regards Efrint
|
|
|
Re: [newton] ent_move command???
[Re: Marcio Esper]
#49632
07/24/05 06:48
07/24/05 06:48
|
Joined: Sep 2004
Posts: 1,214 Austin, Texas
Josh_Arldt
Senior Developer
|
Senior Developer
Joined: Sep 2004
Posts: 1,214
Austin, Texas
|
@Efrint are you trying to make the player have collisions with/effect the newton objects(like in HL2 or Far Cry)? If you are they way you are doing it is terrible and won't work... The way you do it the physics properties for the player will not be updated(the physics collisions ect will not follow him). This will result in a player that just falls through the floor. Instead you have to make a seperate object for collisions and update them in the direction if the player by adding impulses. Maybe tomorrow I can upload a little open-source demo for you to look at.
|
|
|
|