Hello,
how can I get the altitude of an object regarding the distance between the ground and the object?
Does someone have a script?
Greez André
Hello,
how can I get the altitude of an object regarding the distance between the ground and the object?
Does someone have a script?
Greez André
How good are you with python?
What I would do is have a ray pointing down (global axis) and then using the ray distance python command to get the altitude between it and the nearest lower object.
problem is I don’t know any python… when I see a script I understand what it is meant to do, but I don’t know any commands by heart. That’s why I need help with that.
The value that the ray distance python returns, in which unit is it measured?
Greez
I actually know very little python from memory as well, so I frequently refer to the API, or to google…
I’m just in the process of making a tut on this, and I’ll give you a link when it’s done
Here you go
As a PDF. If you have any more questions, just let me know
There is also an example blend if you need it
Nice tutorial, learnt a new command :round- at the minute I am using abs to make floats into integers but I wondered how to do decimal places.
Cheers!
Paul
BTW, if you are doing more tutorials, why not do one on free roaming AI? I’d be interested in how your game deals with this.
No probs. I enjoy writing scripts/tuts for other people as it helps me to get to know python better too.
It seems that the “round” command acts slightly differently in game engine python. I can’t get it to round to more than 1 decimal. In normal python that second number actually does something, but in the game engine it seems only 1 and 0 have any effect.
It’s good enough for this purpose though.
BTW, if you are doing more tutorials, why not do one on free roaming AI? I’d be interested in how your game deals with this.
AI heh, I’m having enough issues with that at the moment. My turret script is working properly, but I haven’t even addressed movement yet. That will be happening over the next few weeks I guess.
I also guess that you had a look around the rest of my website…
cool, thanks a lot!
Really? That’s odd. It should round off by the second number, like you said:
round(0.123456, 0) # 0
round(0.123456, 1) # 0.1
round(0.123456, 2) # 0.12
Is this not what’s happening?
That’s what I though, and what I’ve used outside of python, but if you go get the example blend, and change that number to 2, or 3, or 7 it will still come out as 6.3. The round function may need the math module to work properly.
As it is, the blender text editor doesn’t recognize it as a function, but it still kindof works
Huh. The URL’s broken. In any case, it shouldn’t be a problem, and the round function shouldn’t need the math module to work properly… That’s really odd…
Worked as expected to me. I think you might be confused if the number seems to ‘magically’ rise, even beyond the rounding, but that’s because it ‘loops’. Here’s what I got:
Actual Height, Rounded Height with round(altitude, 1)
4.985824… 5.0
Again, this time with round(altitude, 2)
4.985824… 4.99
That makes since, because rounding it off to 2 positions would give you 4.99, and rounding it off to 1 position would give you 4.99 minus a digit, and rounded up, making it 5.0. It worked fine for me with another value, as well (2.69349, round(altitude, 1) = 2.7)
EDIT: Double post, accidentally. Sorry.
Oh, you’re right. Sorry bout that, Just double checked and I mucked up there… (Using the grid, of course it won’t get any more detail than 6.0!)