I need some help with a few issues I have come across during production of my game.
These problems could be due to my overall experience of BGE, but I’m sure you all aware of the problems I am having. Any help would be great thank you.
Seeking newly spawned in units from another layer. I’m guessing this has something to do with object being named “object.001” etc when they are being spawned in but I cant get anything to seek any object from another layer.
Creating paths for objects, I have created everything for an object to move on a path, and this happens during playback from the timeline, but when the game engine is engaged the object hits dead center. I have done every tutorial I can but for some reason when I get everything setup the object goes to dead center. I’m guessing this has something to do with finalizing the path or something?
These problems are holding my game back so I hope you understand my frustration. But I also know Blender has a very large learning curve. And most terms are new to me. Been using blender for about 3/4 years so any help on these issues would be greatly appreciated.
Thank you, I watched it. I can code this stuff but I’m looking to make some basic commands to basic objects. This is the mad world of blender “old washed out BGE”.
This video is completely not what I need. I need to be able to seek spawned units from other layers, and follow the path of a “path” with an object.
seeking objects is not hard, you know python so go trough the objects, put the objects you want to look for into a list, now you can select an object from that list to seek to.
so for example you can do…:
def test(cont):
own = cont.owner
#grab the objects one time at start
if not 'first_time' in own:
own['obj_to_seek'] = [obj for obj in own.scene.objects if 'property' in obj]
own['first_time'] = True
#now do with it what you like
own['obj_to_seek'][0] #first entry
#or
for obj in own['obj_to_seek']:
if obj['look_for']: #look_for property in the object set to true then..
#code to search for the obj
own['search_object'] = obj
if own['search_object']:
#let the player or something search for that object here
#or follow the path to it
def test(cont):
own = cont.owner
#spawn object
added = own.scene.addObject('name_of_obj_to_spawn', 'spawn_location', 0) # 0 = no duration so unlimited time
#if you using the steering brick then you can set the taget like this
steer_brick = cont.actuators['the name of steering brick here']
steer_brick.target = added
cont.activate(steer_brick)
i believe this are the commands for the steering brick, not completely sure due to i don’t use bricks.
No why? BGE stays BGE, bge 2.79 or upbge 0.2.5 all use the same coding. The code won’t be removed, changed yes, some things have been added or changed a tiny bit but other then that the code is (t)here forever.
However the BGE itself has been removed from blender version 2.8 and up, so if you want to use the evee render then you should download upbge 0.3.0 and even then the python code is still there to be used. (maybe not everything, dunno not using 0.3.0 myself).
Sure you can. Your logic brick is probably still referencing the original object. You can use Python to change the target to the newly spawned object.
Try not to reference things by object name. Instead, keep a reference to the object made by the “add object” by invoking it in Python and capturing the last created object.