Unity and Blender

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)

“will I need to rescript the object in Unity”? Yes.

Blender was/is primarily a 3D modeling & animation program. And those are what it can export, to Unity, say. Even a scene, it’s probably better to just export the objects and remake the scene in Unity. The Blender “game engine” was added later, was pretty sucky, then was improved. But it’s one of those weird things openSource projects get, because they can.

The fastest way to convert that script to Unity would be to watch what it did in Blender. Not bother reading it. Then write it from scratch in Unity to do what you just saw. The part about frames 1-40, that wouldn’t even be in the script.