Hooking an object (parenting?) Blend included

I had an idea that i think is doable with the Game engine using parent actuators but i never used parent act. Here is a blend i started It has a custom made cursor. It’s a bit of a mess. In a invisible layer is a hook pressing A key adds hook and line to scene S deletes the hook. I want the hook parented to cursor but in the middle of the scene (So
when i move hook up and down side to side, i can snag my objects that are in the scene) I need to see the hookup i can try to snag object by moving mouse If i snag the object near it’s mouth it should be parented to hook and of course i will have an action animation triggered until i release object I also want the hook to swing if i move the mouse back and forth maybe even use softbodies for the line making it move like fishing line. The odd thing is the interface looks like 2.48 which i never used, this was made in 2.49( look at the physics part dynamic, rigid, etc it looks like 2.48 )Problems with it are this first the hook disappears( that because it is moving don’t know why.Next it only moves up and down. and can’ get softbodies to work. Finally i appended the custom cursor from one of my blends not sure if that is why the interface looks that way
If someone wants to try and fix it up go for it or at least point me in the right direction

digiman

Attachments

hook.blend (486 KB)

I have downloaded you hook.blend I fixed the code to Blender 2.49b and the hook is now moving with the cursor and is not disappearing any more.
It is better to use rigid body joints for the fishing line (performance).

But I have some questions:

an action animation triggered until i release object

  1. How do you want to release the fish?

I want the hook parented to cursor but in the middle of the scene (So when i move hook up and down side to side, i can snag my objects that are in the scene)

  1. Do you want that the hook is always in the middle of the screen or only when you start fishing?

I also want the hook to swing if i move the mouse back and forth

  1. How do you want to swing when the hook is always in the middle?

  2. The fishes move in xyz direction. Do you want to sang the fishes in the front and behind the hook also?

Forget all of that I solved the first part of it. I just need to take care of a few more problems that i have not had time to look at. Open the new blend .The hook i want parented or constrained to cursor (don’t have a clue on how to do that) Because the cursor moves only 2D
i will need the hook moving somewhere in the middle.I can change where it is in the scene later. Next if i move the mouse it would be cool to have the hook swing what would even be better though i am not sure if possible use softbodies so the string looks real but i will settle for anything i can get. I tried using softbodies and it was a mess. Finally, i will add that hook from another layer and of course delete it when i don’t need it, that part is easy to do. .I need those 3 things. I am just not sure if i have to parent or constrain or what exactly. Look at this new blend below strangely the animation that plays when the hook touches the cube does not last even though it is set with edge loop

digiman

Attachments

Parent2.blend (483 KB)

I can live without a few of what i asked for All i really need is one thing. Once I add the hook to my scene I just want it parented to mouse automatically so when i move mouse the hook moves. I have been trying to do that but i really don’t have any idea on going about it

digiman

The hook i want parented or constrained to cursor (don’t have a clue on how to do that) Because the cursor moves only 2D
i will need the hook moving somewhere in the middle.

I can make every movement to the hook. But I need to know how you want it.
mouse up/down --> hook up/down local Z-Axis
mouse left/left --> left/right local X-Axis
or
mouse up/down --> hook up/down global Z-Axis
mouse left/left --> left/right global X-Axis
or
mouse up/down --> hook up/down global Z-Axis
mouse left/left --> left/right angel between X and Y-Axis depending on the camera rotation to the wolrd center

I am not sure how to answer that .I know very little about local and global I always used the defaults. I can tell you the camera will not be moving. I am guessing one of the first two options, probably the second but i don’t know Maybe if you try using that little practice fish that might tell you more if you hook it. That’s not much of an answer If you need to ask me something else let me know maybe i can be more help

digiman

does this help?
Hook.blend (187 KB)

I haven’t really read too much in the thread, but I think I picked up the jist of it…

EDIT: Also, controls-
wheel up - zoom in/ zoom out
left click - orbit view left
right click - orbit view right
mouse move - move rod

I was going to add some interpolation with weightings, to make the string bend, but it seemed like too much work, but I would be glad to give it a try later, just ask…

@ Haker23 Very nice example. You saved me a lot of time. I keep your file for the future.
@ digiman That example shows the last option. So I think that was what you want.

Thanks, glad I could help. One thing to note, you need to parent everything (fish, plants, etc) to the emptymesh “World” because I couldn’t parent the rod to the camera as it applys the co-ords locally in camera space, and if I changed the rotation of the rod, track to, etc, it moved only in global co-ords, and would only move in one plane (XZ co-ords). So I just made everything else rotate around the camera and rod.

I got rid of rotating, zooming which i don’t need but the main problem is that i can’t get much control with hook because the line stretches so mouse is at the edge of screen and the hook is pretty much in the same place more or less. Maybe try my parent2 blend and just parent that hook to mouse.

digiman

in my file? if so, the rod object has a “scale” property, scale it up till it works for you.
(Should have mentioned this).

I think it could be to do with the monitor resolutions - the mouse co-ords definitely are taken from the resolution, as the bottom right co-ords of my screen are the resolution of my screen. So the conversion is basically from screen co-ords to world space, and will need tweaking here and there; although this should be eliminated if you run it in a stand-alone executable, etc, as these will give the same resolution regardless of the screen.

@Haker - You mean ‘scaling’, not ‘scale’, unless you’re talking about a user-defined property.

Yeah, the first i tried was that but there are other problems with No matter how much i scale movement is limited Also The line stretches out so when i capture my object the line keeps stretching I can’t pull the fish object. And am having trouble when i release parent fro some reason After looking at your blend and it came out well i think what i need is for hook directly to the cursor, i will get better control as well. look at my parent2 blend If you can use python to set it to the cursor it would be best. then i can just add or delete hook into scene as i need it. Yours is great but i can’t get it to work the way i need. Unless you know how to get rid of that stretching and movement. My goal was once fish is hooked an animation would play of the fish trying to get away and i would also be able to pull fish, like it is now i can’t I tried it in blenderplayer to see how it would work as an excutable but still same problems

digiman

Thanks anyway that game seemed to have the same problems i had been having. I think the best bet is to use the hook I made in parent2 blend and set that to cursor. too bad you need python to do that. Maybe someone else knows how to do that

digiman

Monster did by using a mouse over, this has a hit point attribute/function I think, so you can place the object centre screen and then use the mouse over connected to a python script, this gets the hit point and places the object (in this case a hook) at that point. quite a clever workaround.

Do you have a link? If not i can just ask him. By the way that fishing pole of yours looks so cool, if i could get rid of those problems, imagine being able to reel in the fish once it is hooked that would be incredible, but i will settle for my hook to the cursor

digiman

I was trying to make an element where the fish could wriggle free, but I think youe idea is much more obvious - you could have to repeatedly tap a button, if you don’t you lose the fish if you do, you catch it… great idea

Ah, you mean the S2A. Look for hitPositionToPosition.

Here is what you need:
Something to collide with (e.g. a plane) at the position you want to have the cursor. It can be invisible. There can be multiple objects e.g. your environment objects.

You need an object to act as Cursor.

Now do this at the cursor:
Mouse sensor “over any” TRUE Pulse! -> Python MODULE:S2A.hitPositionToPosition -> any actuator (will not be activated)
Mouse sensor “left mouse button” ->

That is all

Remarks:

To affoid side effects:
Make sure if you have (face) collision on at this object, the objects center should be pointing towards the camera and outside the object.

X=object center.
camera -----line of sight ----------------->X mesh

The reason is simple: if you have it like that:
camera -----line of sight ----------------->mesh X
the next frame the object will be place at
camera -----line of sight --------->mesh X
and the next
camera -----line of sight ->mesh X
until it crashes into the camera

Alternative:
Parent your mesh at an empty. The empties center should be between camera and mesh
Now you apply the above logic to the empty rather than to the mesh. The mesh will follow the empty as they are parented.

I hope it helps

Yeah, that’s what i need, but i can’t apply it to my parent2.blend. perhaps because i am using a custom cursor, not sure why.

digiman

It should not matter. The code does not even need a visible cursor. But if you reset the mouse position to the middle of the screen, this will not work, as mouse over sensors will not work as expected.

Another possiblity: if your custom cursor has collision on, it might be detected by the ray of the mouse sensor. That is what I explained in the Remarks section. Try to turn it off.