4
$\begingroup$

I did a little "realistic" buggy test, please watch my video (I'm french but I did the video in English).

I just have a little issue, see the python console and my explanation in the video or in the picture below.

The problem is when my ray sensor no longer detects the ground (When car is in mid-air.) It generates an error in the python console and decreases the framerate of my game (especially in full screen). I don't know how to fix this in my script.
This error occurs when my ray detects nothing in its range.

Here's a picture:

http://imgur.com/TN3jewQ

Here's the video: https://www.youtube.com/watch?v=fAOVMnYo-ao

$\endgroup$
1
$\begingroup$

You already know what is causing the problem, it is because your script is trying to loop through a empty list (when the ray sensor is not hitting anything.)

All you have to do to fix it is add one line to your script.

if sol:
    #then your if statements goes in here

or change your if statement to this:

if sol and 'Sable' in sol and own['Vitesse'] > 10:

That one line checks to see if your ray is hitting anything, if it is then the rest of your logic will run. If the ray hits nothing, then there is no error because nothing happens.

$\endgroup$
  • $\begingroup$ Thank you dude, i starting in python and its not easy. it is possible to contact you for more blender answers? $\endgroup$ – Hack0re Sep 15 '15 at 18:45
  • $\begingroup$ Sure, you just ask another question (if it is somethinf you think is not worth an entire question you could ping me (just type "@david") in the chat.). PS since this answer helped you, you should accept it. $\endgroup$ – David Sep 15 '15 at 20:58
  • $\begingroup$ I will create another question for my others problem, thank you. $\endgroup$ – Hack0re Sep 15 '15 at 21:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.