general script setup (storing values)

Hi everyone,

I got a very basic question about setting up scripts for the BGE.
For better understanding, I will give an example:
Lets say, I calculate the distance between two objects each frame. Object A is moving all the time, object B stands still. Now I hit a key and from that point, I want object B always to keep the same distance to object A.
(It is not about parenting or something like that, it is about storing that offset-value)
Is there any other way than giving it to a property? I will have at least 42+ objects later on for which I will have to do this in position and orientation. That means at least 294 values :eek:

First I was thinking of just making the offset position and orientation global, but as the script always starts completely new on each frame, the values are not stored of course :confused:

Would be great if someone could help me out with this :slight_smile:

Greetings,
Quen

confusing!

What are you doing with the calculated distance?

If the distance do not change anymore, you should always get the same value.

you can use the object like a dict to store properties:

obj[“prop”] = value

Yes right, basicly it will not change anymore, but there will be certain situations when that value has to be modified.

Thank you very much for the hint, how to store values in objects! I just did not know about that.
I think that will work for me very well, thanks again. :slight_smile:

i think that parenting the objects and removing them when needed using the parent actuator is better than storing offset values because the script you are using to store the offset values may be actually storing the global locations. but (i think) you are really looking for the offset location relative to the other object when needed.

And since you are to work with 42+ objects implementing 42 python scripts is not cool
Try to keep everything simple.