Can someone help me in scripting? I’m having difficulties on making objects fight. I use VectTo, TrackTo and many more. I downloaded the S2A but i cant get the setup. Can someone assist me here?
is a bit vague.
What exactly do you want?
Before you do any scripting, you need to make clear what exactly you want.
If you have complex logic, split it into smaller parts until you can handle it.
The basic question you should asked yourself: What should happen when?
Beside that, there are some references to Python tutorials in the resources forum. I recommend “byteOfPython”.
What I want to happen is, the object will track another object if it has a property of the name I want. For example, Object1 will track object 2 because it has the property name that will make it track. I’m doing this because I dont want to put many property and track actuators on my logic brick. SunJay told me that if I want to make them fight, I must put one property on all object and put it on a script.
You are right the trackTo actuator is what you need.
You said you tried S2A. I think that is the right way. See this thread: http://blenderartists.org/forum/showthread.php?t=184482 for an example.
If you use hitObjectToObject or closestHitObjectToObject together with an near sensor you can let the trackTo actuator change the tracked object when the near sensor fires. The near/radar sensor already provides you with the option to detect objects with a special property only.
cont = GameLogic.getCurrentController() own = cont.getOwner #sensor near = cont.sensors["near"] #Actuator track = cont.actuators["track"] motion = cont.actuators["motion"] #process if near.distance: if ['Unit'] == ['Zerg']: track.getHitPosition()
this is the code that I wrote. How do you write trackTo anyway? should it be trackTo(object name) or trackTo(property name?) could you do a sample how to write it? plss
= checks if the parameter distance is not None and not 0.0.
- It never can be None as Blender does not allow a None value.
- If you have 0.0 in here the sensor is setup incorrect.
- => it is always True and therefore not necessary
if [‘Unit’] == [‘Zerg’]:
builds a list with the string “Unit”
builds a list with the string “Zerg”
compares this two lists
obviously this lists do not have the same content
=> it is lwyas False and the code in the execution bloack is never executed
trackTo is an actuator please check the API for available members
it does not have getHitPosition() this is a member of the near sensor
what you need is
near = cont.sensors["near"] track = cont.actuators["track"] if near.positive: track.object=near.getHitObject() cont.activate(track)
This is what S2A.hitObjectToObject already does.
It works but it doesnt chase the enemy. It just move a little bit. How do I make it chase the enemy with a property in it? Like it will chase the object if it has a property name that will chase it?
any help at all?