UPBGE / upbge

UPBGE, the best integrated game engine in Blender
https://upbge.org
Other
1.42k stars 179 forks source link

[Request]Steering to position #600

Open Jesusemora opened 6 years ago

Jesusemora commented 6 years ago

The Steering actuator has an option to follow a target object, but this option is useless because of how the objects are cloned when added and they share the same name. There is a way to use pathfinding with python to go from a position to another, but this does not work with obstacle simulation. The only way to use obstacle simulation is with Steering actuator. What i ask is for the option to use a position (and being able to change it from python) instead of a target object name, in the Steering actuator. Target object may not even be necesary, since we can use obj.worldPosition instead. this will facilitate making games with dynamic environments and multiple friendly AIs, wich could be needed in FPS, RTS, RPG, and even platformers and racing games.

BluePrintRandom commented 6 years ago

do you know python? navmesh.findpath() is very handy

On Sep 25, 2017 9:56 AM, "Jesusemora" notifications@github.com wrote:

The Steering actuator has an option to follow a target object, but this option is useless because of how the objects are cloned when added and they share the same name. There is a way to use pathfinding with python to go from a position to another, but this does not work with obstacle simulation. The only way to use obstacle simulation is with Steering actuator. What i ask is for the option to use a position (and being able to change it from python) instead of a target object name, in the Steering actuator. Target object may not even be necesary, since we can use obj.worldPosition instead. this will facilitate making games with dynamic environments and multiple friendly AIs, wich could be needed in FPS, RTS, RPG, and even platformers and racing games.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/UPBGE/blender/issues/600, or mute the thread https://github.com/notifications/unsubscribe-auth/AG25WTvsX-UTpHPUacxWJg-wH-MPFdDgks5sl9s8gaJpZM4PjCVv .

Jesusemora commented 6 years ago

do you know python? navmesh.findpath() is very handy

There is a way to use pathfinding with python to go from a position to another, but this does not work with obstacle simulation. The only way to use obstacle simulation is with Steering actuator.

navmesh.findpath() does not work with obstacle simulation. it only works with a static navmesh, it does not avoid objects that are not in the navmesh or objects that are moving or added, wich steering does.

youle31 commented 6 years ago

actually, I think what you want is possible: http://pasteall.org/blend/index.php?id=47925 but tricky (it seems there is a bug with sensor.status)

Jesusemora commented 6 years ago

i looked into the code in source/gameengine/ketji/KX_steeringactuator.cpp m_target is the target object in the actuator, this is all the actuator does with it: const MT_Vector3& targpos = m_target->NodeGetWorldPosition(); i think it gets the position. there are other lines of code, i think they are to check if m_target is an object: if (m_target) m_target->RegisterActuator(this); how hard would it be to give the actuator the position instead of an object? the only problem would be those who are already using it as it is. maybe we can put a toggle button to use position OR object?

BluePrintRandom commented 6 years ago

if type(target) is object: convert to vector proceed assuming input is vector?

On Oct 4, 2017 6:41 PM, "Jesusemora" notifications@github.com wrote:

i looked into the code in source/gameengine/ketji/KX_steeringactuator.cpp m_target is the target object in the actuator, this is all the actuator does with it: const MT_Vector3& targpos = m_target->NodeGetWorldPosition(); i think it gets the position. there are other lines of code, i think they are to check if m_target is an object: if (m_target) m_target->RegisterActuator(this); how hard would it be to give the actuator the position instead of an object? the only problem would be those who are already using it as it is. maybe we can put a toggle button to use position OR object?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/UPBGE/blender/issues/600#issuecomment-334336138, or mute the thread https://github.com/notifications/unsubscribe-auth/AG25Wc4wet0eIzgQPQkUnRfDrvNzHTJlks5spDPjgaJpZM4PjCVv .

Jesusemora commented 6 years ago

if type(target) is object: convert to vector proceed assuming input is vector?

yeah, something like that. many python functions already acept both an object or a "vec3" position, like navmesh.findpath(), obj.getVectTo(), or scene.addObject(). it would be a small change that would allow simpler scripts. an enemy can find a target with radar, then we get the objects from the sensor, get the position, and put it in the steering actuator. then we get more complex AI, that can attack allies, we can set decoys, we can do all kinds of things that are much harder with how it works now, and we avoid most of the bugs caused by cloned objects without extra code in the scripts, because the sensors do not pick objects by name, they pick the detected objects.