[Bf-funboard] bge proposal : having python scripts for sensors, (controllers) and actuators

Campbell Barton ideasman42 at gmail.com
Mon Oct 20 03:09:29 CEST 2008


Hi Jonathan-David, you raise some valid points.

Carsten, the issue I found was even though everything I wanted was
possible in Apricot logic, some things ended up being done in a way
that did not fit into BGE logic bricks well.

Take ledge grab for an example (where frankie hangs onto a ledge).
This could be a sensor that checks -
(Is a ledge in front of me && the ledge top is less then # distance
above me  && Im airborne && Im not carrying a sheep)

The reason this would be nice as a sensor is that the logic for ledge
grab was used in 3 places - for attaching initially (gliding or
falling), and while hanging onto the ledge and moving from side to
side.

Since it could not be a sensor, I made it into a script that runs on
startup and assigns a function to the GameLogic module - so both
pycontrollers could use the same functionality. Normally Id make a py
module but that dosnt work in the BGE.

Even though having this logic in 1 sensor would be nice Im still not
convinced that python sensors are the way to go. Mainly because its
moving away from visually editing logic which I dont think we have
taken full advantage of yet.
Also it would have to run a python script for every logic update (60
times a second). Whereas with Py controllers you can limit how often
the scripts run to reduce overhead (with sensor pulses).

It could be interesting to be able to define a group of sensors. so
you could add all sorts of checks then re-use this in many places.

Groups could be defined in the interface - and then have a group
sensor type - OR - (easy but ugly) method could be to simply have a
sensor that instances all sensors attached to an existing controller.
- Just need to be careful this is not totally confusing for the users.

Then its just a matter of making sure there are sensors to make more
complex logic you need which would be great to have in the BGE anyway.

Having python actuators makes more sense to me because you may want to
do fairly complex operations on an object - control its motion in
space, spin on an arbitrary axis, limit its velocity on an axis etc.
but the overhead of having more scripts running makes me less excited about it.

even with the overhead of scripts, the nice thing about python sensors
and actuators is you could prototype new logic bricks very easily,
then re-do them in C and swap in the faster builtin versions.

- Cam

2008/9/17 Jonathan-David SCHRODER <myselfhimself at free.fr>:
> Hi
> if you really start creating your game logic by thinking that the controller
> IS the brain that controls everything, then you can make something clean.
>
> in the case of sensor that should be things that think... for a python
> controller to trigger some action, it decides what to do on :
> -which sensor called it (someSensor.isPositive())
> - and some things it can observe by himself by reading various objects'
> properties/situations.
> those things it can observe could be put in the the sensor section instead
> as real sensors and made reusable. That's why I propose having python
> sensors.
>
> For example, there's no sensor for... seeing if some external object's
> property is equal to something (there's a local property sensor, but not an
> external property one)...
>
> maybe, the same way there are pynodes which help pack helpful and often used
> node python code, there could be pynodes for sensors.
>
> anyway indeed as you state, everything is doable in the GE... so I should
> not try to split hairs.
>
> jonathan
>
> On Tue, Sep 16, 2008 at 11:19 AM, Carsten Wartmann <cw at blenderbuch.de>
> wrote:
>>
>> Jonathan-David SCHRODER schrieb:
>> > Hi
>>
>> Hi!
>>
>> > My final proposal is :
>> > 1) make sensors able to be scripts
>> > 2) controllers are scriptable this is ok
>> > 3) make actuators able to be scripts
>> >
>> > What do you think ?
>>
>> I really cant see (maybe your examples are to unspecific) what this
>> could help.
>>
>> You can controll an object from a controller without any actuator
>> (visibility, mesh, pos, orientation etc.) So many things are already
>> possible. Maybe you also want to play Ipos? Well what is so bad about
>> having an (named, this helps) Actuator?
>>
>> For the sensors: I dont think it would be wise to make some script
>> sensor. Can your eye think? ;-)
>>
>> I think the logic system has its flaws but it proved in the last years
>> that it is working in the way it was designed (SCA like in a living
>> thing), we can (I think) do nearly everything with it, and the python in
>> the controllers unlocks the rest.
>>
>> Best regards,
>> Carsten
>>
>> --
>> Carsten Wartmann: Autor - Dozent - 3D - Grafik
>> Homepage:         http://blenderbuch.de/
>> Das Blender-Buch: http://blenderbuch.de/redirect.html
>> _______________________________________________
>> Bf-funboard mailing list
>> Bf-funboard at blender.org
>> http://lists.blender.org/mailman/listinfo/bf-funboard
>>
>
>
>
> --
> http://www.jaxtr.com/myselfhimself
>
> _______________________________________________
> Bf-funboard mailing list
> Bf-funboard at blender.org
> http://lists.blender.org/mailman/listinfo/bf-funboard
>
>



--


More information about the Bf-funboard mailing list