Gamestudio Links
Zorro Links
Newest Posts
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Newbie Questions
by AndrewAMD. 12/04/23 11:14
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
2 registered members (TipmyPip, izorro), 556 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
velocity to apply considering distance #99674
11/23/06 10:24
11/23/06 10:24
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline OP
User
demiGod  Offline OP
User

Joined: Mar 2006
Posts: 752
Portugal
Hi,
I have been trying for sometime to adapt a code to work with the physics engine. I want to automaticly calculate the velocity to apply to an object via phent_addvelcentral, considering the distance to be covered between the object position and a target vector in a way that the object moves and accurate aims the target.

I need this calculation for stopped and moving objects and targets. I have this code that doesnt use the PE:

Code:

var vSpeed;
var vTarget[3] = 0,0,0;
var distBetweenObjTarget[3];

action testObj
{
var vAccel;
var vMove;
var iSpeed = 2;
while(1)
{
//turn towards target
vec_set(temp,vTarget.x);
vec_sub(temp,my.x);
vec_to_angle(my.pan,temp);
//calculate distance between obj and target
distBetweenObjTarget = vec_dist(my.x,target.x);
//calculate velocity to apply
vAccel.x = iSpeed * distBetweenObjTarget[0];
vAccel.y = iSpeed * distBetweenObjTarget[1];
vAccel.z = iSpeed * distBetweenObjTarget[2];
vec_accelerate(vMove, vSpeed, vAccel, 0.5);
c_move(my, vMove, nullvector, glide);
wait(1);
}
}



I´ve ran several tests but i cant find a way to do this with the physics engine, because i think the ODE solver gives different results from physics formulas and euler approximations.
So, using the PE how can this be done?

Should i retrieve the velocity and angular velocity via phent_getvelocity and phent_getangvelocity and use that information, or in the other hand, i need to use the mass, friction and other values to be calculated like acceleration?
I really appreciate some help on this matter.
Thanks.

Re: velocity to apply considering distance [Re: demiGod] #99675
11/25/06 12:56
11/25/06 12:56
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline OP
User
demiGod  Offline OP
User

Joined: Mar 2006
Posts: 752
Portugal
Hey, where are the physics gurus on this forum?
Are they gone or nobody are using the 3dgs PE?

Still waitting for some help.

Re: velocity to apply considering distance [Re: demiGod] #99676
12/24/06 15:05
12/24/06 15:05
Joined: Sep 2005
Posts: 274
Switzerland - Zurich
zwecklos Offline
Member
zwecklos  Offline
Member

Joined: Sep 2005
Posts: 274
Switzerland - Zurich
Heyho
Im not really a Guru but I try to help you

You could try to increase the friction when your object come close to the target position, this could be done with tracing.

An other way could be to decrease the force when the object come close to the target vector.

if(distance > 5)
{
moving_force.x = 100;
moving_force.y = 0;
moving_force.z = 0;
}

if(distance <= 5) && (moving_force.x != 0)
{
moving_force.x = -20;
moving_force.y = 0;
moving_force.z = 0;
}


phent_addvellocal(object, moving_force, nullvector)

Maybe something like this could do the job. You just have to set the objects right orientation before moving it. phent_addvellocal let you use forces dependent to the objects orientation.
When you reset to objects orientation (x, y and z coordinates) make sure that you disable your physic entity while doing that (phent_enable).

I hope this helps a bit

cheers

zwecki

Re: velocity to apply considering distance [Re: zwecklos] #99677
12/24/06 15:29
12/24/06 15:29
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline OP
User
demiGod  Offline OP
User

Joined: Mar 2006
Posts: 752
Portugal
Hi zwecklos,
actually i dont want to use the objects orientation dependency. Imagine a player with a ball and a given point / vector. I need to automaticly calculate which velocity i need to apply to the ball (independent of its pan / orientation) in order to the ball reachs exactly that point and stop right there. The code above do that, but i need to use the physics engine.

Re: velocity to apply considering distance [Re: demiGod] #99678
12/24/06 16:10
12/24/06 16:10
Joined: Sep 2005
Posts: 274
Switzerland - Zurich
zwecklos Offline
Member
zwecklos  Offline
Member

Joined: Sep 2005
Posts: 274
Switzerland - Zurich
ah now I can see more clearly what you are going to do
Are you on a soccer/football game?

cheers

Last edited by zwecklos; 12/24/06 16:18.
Re: velocity to apply considering distance [Re: zwecklos] #99679
12/24/06 16:38
12/24/06 16:38
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline OP
User
demiGod  Offline OP
User

Joined: Mar 2006
Posts: 752
Portugal
Something like that but with other style and gameplay. Unfortanly my physics knownledge and the 3dgs physics engine support will probably kill down this project... well, new year, new life


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