I spent the last to days searching how to build a seek behavior my ai and i have yet to find anything usefull.
most seek behavior assume that you can just apply a new force to your body to change it's direction. But it my case i need the ship to ajust it's orientation to turn it's main thruters in the right direction but i have yet to find the proper way to calculate apropriate torque forces to ajust the orientation of the ship. also i will need to have the forces applied in local space because the rotation are performed by an internar yaw roll and pitch control.
At this point it's giving me nightmares and i can't figure it out.
Whay have you guys tryed in Ai behaviour? or anyone is good enough at math to help me figure it out?
Steering behaviors orientation and space conversion
Re: Steering behaviors orientation and space conversion
If you don't know enough math maybe you can fake it (games are all about faking stuff good enough). 2 ways I could think of:
a) Don't let the AI use real physics. Let them follow some bezier curves instead which just look good enough.
b) Try if it's sufficient to segment your search-space and find steering values for each value-range. For example with 2 dimensions - original speed and target direction you could for example have 10 steps for speed and let's say 16 for target direction. Makes 160 situations for which you have to figure out control values to get your object turn into the right direction. I must admit I don't know if this will work for more complex steering as with each dimension you add (for example target speed) the space will grow rapidly. Finding those values is maybe done by moving around yourself and recording your own reactions.
Or well - dig into the math. Maybe it's not as hard as it looks like and if you succeed you are better at math afterwards which is always worth a lot :-)
a) Don't let the AI use real physics. Let them follow some bezier curves instead which just look good enough.
b) Try if it's sufficient to segment your search-space and find steering values for each value-range. For example with 2 dimensions - original speed and target direction you could for example have 10 steps for speed and let's say 16 for target direction. Makes 160 situations for which you have to figure out control values to get your object turn into the right direction. I must admit I don't know if this will work for more complex steering as with each dimension you add (for example target speed) the space will grow rapidly. Finding those values is maybe done by moving around yourself and recording your own reactions.
Or well - dig into the math. Maybe it's not as hard as it looks like and if you succeed you are better at math afterwards which is always worth a lot :-)
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Steering behaviors orientation and space conversion
Actualy i did dig into the math
this is what it gave it seem to stear somewhere but it does not stear toward the target
Code: Select all
btVector3 Steering::steerForSeek(const btVector3& target, const btQuaternion &Orrientation, const btVector3& Position)
{
btVector3 EulerRotation;
hQuaternionToEuler(Orrientation, EulerRotation);
btVector3 desiredVelocity =(target-Position);
desiredVelocity.normalize();
desiredVelocity -= EulerRotation;
btVector3 r = desiredVelocity;
btVector3 angle;
angle.setY(atan2 (r.x(), r.z()));
angle.setY( angle.y() * (180 / core::PI));
if(angle.y() < 0) angle.setY( angle.y() + 360);
if(angle.y() >= 360) angle.setY( angle.y()- 360);
angle -= btVector3(0,90,0);
return=angle* myRigidBody->getWorldTransform().inverse().getBasis();
}
Re: Steering behaviors orientation and space conversion
What is about?
You pass in quaternions, but then you forget all about them.
Anyway, you have orientation, angular velocity, position and velocity. Find the distance to the target and the angle to the target and the axis of rotation to rotate to the target. Now it is easy. If the distance to the target is greater than half sqr(current speed)/max acceleration and current speed is less than max speed, you can increase speed by the maximum acceleration. If you are at the max rotational velocity then you can stay there if the axis of rotation is the same as for the previous frame, otherwise you can increase it by the max rotational acceleration, as long as you can slow the rotation down. Basically, you need half sqr(curr rot vel)/desired rotation to be less than the max rotational acceleration.
Code: Select all
desiredVelocity -= EulerRotation;
You pass in quaternions, but then you forget all about them.
Anyway, you have orientation, angular velocity, position and velocity. Find the distance to the target and the angle to the target and the axis of rotation to rotate to the target. Now it is easy. If the distance to the target is greater than half sqr(current speed)/max acceleration and current speed is less than max speed, you can increase speed by the maximum acceleration. If you are at the max rotational velocity then you can stay there if the axis of rotation is the same as for the previous frame, otherwise you can increase it by the max rotational acceleration, as long as you can slow the rotation down. Basically, you need half sqr(curr rot vel)/desired rotation to be less than the max rotational acceleration.
Re: Steering behaviors orientation and space conversion
it's about knowing the diference betwen my current angle and the one i need to look at
i pass in quaternion because bullet works in quaternion i then convert them to euler
i pass in quaternion because bullet works in quaternion i then convert them to euler
Re: Steering behaviors orientation and space conversion
reverse reciprocal speed is an interesting topic. search for it
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me