Hello, I want to make an object a child of my player object, when I bump into it.
I’ve seen code which uses the makeParent method of oython objects but I can’t make it work.
I also can’t figure out how to know with which abject I’m colliding and assign it to a variable.
¿how do I do this?
Show me that code.
I also can’t figure out how to know with which abject I’m colliding and assign it to a variable.
Let’s say your object is named “crate” (no quotes) the following code will return the name of the object, which you can then assign to a variable:
if collision.isPositive():
hitobj = collision.getHitObject().name
#returns "OBcrate" (no quotes)
now I cant find it, I saw it in another computer, but the structure was like this:
someObject.makeParent(anotherObject)
but I think the problem with my version was the way I was capturing the colliding object.
I lost the experiment file in the other computer, I’ll try to make it again and if it doesn’t work I’ll come back here.
umm, makeParent() does not exist
just tested it
maybe is from an old api
Ashid had a dynamic parent tutorial, if only I could remember the URL, you may want to google it. It had something to do with matrices, out of my league at this point.
import GameLogic as g
from Blender import Object
import Blender
Blender.Scene.getCurrent().update()
ob=Object.get(“Camera”)
actobj=Object.getSelected()[0]
ob.makeParent([actobj])
Parent realtime. And how make “unparent” in game ?!
you cant make a parent or unparent it in the ge.
only in regular blender
thats a shame, thanks
Here’s ash’s website (mentioned earlier). Click “dynamic parenting” in the sidebar. I don’t know if it’s what you’re looking for.
You could cheat by replacing the static object with the parented one upon collision
Thanks, the dynamic parenting tutorial will help