I’ve created a blender file which has 2 objects, a bow and an arrow. I followed a blender tutorial and I have implemented a script which (in Blender) when I click the space button, creates an arrow beside the bow, does the pullback animation, and fires the new arrow object. This works great perfect in Blender, it even made it really easy to handle the gravity and force etc.
I’m now trying to bring these objects into Unity and use them in the same way I did in Blender. I have both saved the item as a .blend object and exported it as a .fbx however I’m losing functionality of the bow. (Space bar doesn’t fire the arrow in Unity)
I’m wondering will I need to rescript the object in Unity or is there a way to keep all the functionality while I’ve brought it across? There’s a small python script added to the bow and also a lot of controllers were added while in Blender (I didn’t need to code them, it has a UI to make them)
If anyone can link help me out it would be great. Cheers
Import bge
cont = bge.logic.getCurrentController()
own = cont.owner
pull = cont.actuators["pull"]
fire = cont.actuators["fire"]
space = cont.sensors["space"]
launcher = bge.logic.getSceneList()[0].objects["arrow_launcher"]
if space.positive:
pull.frameStart = 1
pull.frameEnd = 40
cont.activate(pull)
else:
launcher.actuators["add_arrow"].linearVelocity = [-(pull.frame * 15), 0, 0]
pull.frameStart = 41
pull.frameEnd = 46
cont.activate(pull)
cont.activate(fire)