Step by step help?

EDIT: Sorry I put this in the wrong thread, I realize this is a thread for literal blender development, not for the python scripting inside… Can someone move this please? Thanks…

Can anyone go through step-by-step of how to make a python script that makes a block move forward unless there is another object in it’s path, then it turns 90 degrees and continues. I am not new to programming, just new to python in blender and such. So I know programming logic, just not the python/blender syntax.

Thanks in advance.

ok first thing is first, ever make a timer?

this has a few things in it that are important,




import bge

cont = bge.logic.getCurrentController()

own = cont.owner

if 'Clock' not in own:
    own['Clock']=0

else:
    if own['Clock']>1 and own['Clock']<=29:
        own['Clock']+=1

script = basic header

if you don’t have a property called clock, make it,

if clock is more then 1 and less 30 add 1,

How is a timer used in an open loop system? Like I want it to react to any object that is the scene, for appliance of an AI against a player. If you want me to learn the basics, then sure. :stuck_out_tongue:

well, checking this every 5 frames, doing that every 10, etc

makes it cost less,

so aim body every 10 frames,

if attacking is true====and--------move forward every frame

the idea here is you trigger some logic sometimes, and not all of the time.

Uh, I edited your code a little for testing and I ran into… issues…

import bge

cont = bge.logic.getCurrentController()


own = cont.owner


if 'Clock' not in own:
    own['Clock']=0


if 'Drive' not in own:
    own['Drive']=0


else:
    if own['Clock']>1 and own['Clock']<=29:
        own['Clock']+=1
        
if own['Clock']==29:
    own['Drive'] == 1:

The last line has syntax errors… I’m trying to set drive to one, if clock equals 29.

Side-note, 200[SUP]th[/SUP] post… Woot.


import bge

cont = bge.logic.getCurrentController()

own = cont.owner

if ‘Clock’ not in own:
own[‘Clock’]=0
own[‘Drive’]

else:
if own[‘Clock’]>1 and own[‘Clock’]<=29:
own[‘Clock’]+=1

if own['Clock']==29:
    own['Drive'] = 1

##the indents were off and own[‘Dirve’]==1 is for evaluating not setting

if own[‘Name’]==“Bob”: (if the name is equal to bob)

setting would be like this

own[‘Name’]=“Bob”


So python is the pickier version of Java? Lol, just kidding java would have busted me for a hundred other reasons… So how can I tell an object to turn and move forward at a certain rate… Now I see where the timer comes in, sorry…
"

Uh, now it just says “Python script fail, look in the console for now…”…