make character look at an object?

Is it possible to have my characters head rotate like he is looking at a specific object? like not a pre aniamted animation, i need him to follow an object with hes head, is that possible in game engine?

1 Like

Have the head be a separate object. Use the Edit Object ->Track To actuator on the head to point at the designated object. You may need to tweak the axes.

so there is no way in using constraints or anything (exept script) to make him rotade his head?

You can set the head to have an IK constraint with the target being the object you want to follow. Then you have to use an Armature actuator on the skeleton for your character that is set to “Run Armature.”

I whipped up a very simple example: https://drive.google.com/file/d/0B59fehhFH26fakp5ckl4cndPVmM/view?usp=sharing

1 Like

How would you prevent it from rotating to far counterclockwise and to far clockwise?

Yes i want to do this but with arms and upper back, to look up and down.
Lower back to turn left and right, so i can make a aiming system… BUMP!!!

I will need this too. I wanna see some good examples…

How would you prevent it from rotating to far counterclockwise and to far clockwise?

I guess you would need to come up with a system to either change the IK target via python (which I doubt can be done - never looked into it) or what I would probably do would be to have a dummy empty that the head is looking at that is moved to the same location as whatever the object of interest is. Same problem needs to be solved if you were using the “Track To” mentioned by MrPutuLips.

Yes i want to do this but with arms and upper back, to look up and down.
Lower back to turn left and right, so i can make a aiming system… BUMP!!!

I am gonna assume you want something for an FPS? I can think of a couple different ways and I have no idea what any of the pros on these boards would tell you to do. I originally took the time to write up several ideas of how to achieve this (with varying degrees of difficulty and python use. Rather than use more time trying to clearly explain something I made another crappy example file…

https://drive.google.com/file/d/0B59fehhFH26fX1JMVW85UldfbzA/view?usp=sharing

There are some notes in there but mostly I would say you have to play around with things and explore the relationships between parent/child objects and the enormous number of options that Blender provides.

I will need this too. I wanna see some good examples…

I dunno about GOOD examples, but hey, here is an example. The biggest things that helped me learn anything about the BGE were searching this forum thoroughly, downloading files from here and places like Blendswap, running them and making small changes to see how things interact, and watching hours and hours of YouTube with Blender open right beside it.

I do the same, but the TPS rig thing is not very tutorialised and widely explained around - rare people has it and thoose, who has it, mostly keeps it by theirselves and doesn’t share methods and tuts…

step 1 = get simple mouse

step 2 = use properties X and Y to rotate objects

step 3 = use copy rotation in armature bones from objects and run armature

I’ll make a quick demo

Nice to hear that!:wink:

This is brilliant, how do we invert mouse ? so instead of up going down, up goes up ?
Thank you for .blend

Ok, it is not 100% easy to use, but it’s as close as I can get it at the moment,

the only issue I see, is that to animate the bones that are using copy rotation, you will have to

animate the object they are copying from, (offsetRotObjects)

and to animate the gun arm, you have to animate the object ‘IKHOME’

Attachments

AdvancedAimAnimationSystem.blend (549 KB)

in the script text.001 (I did not go through and name everything yet) Rot.y+=own[‘y’]

change that to

Rot.y-=own[‘y’]

And here is all I will be able to do for today

everything should be working

Note: Chest ‘Zeros out’ when not holding left click to aim.

Attachments

AdvancedAimAnimationSystem2.blend (631 KB)

This is good, i really hope we can get this implemented into our games :slight_smile:

just let me know if you have to much trouble.

I´m also planning on making a tutorial on this, since I tried this feature before and might be able to teach it soon.

I had a epiphany at work today…
What if i make a aiming animation stance, the when i right click it just activates that stance.
Instead of moving the arms with the mouse, witch makes no sense, only just move the upper
back to aim up and down and lower back to turn left and right ???

This would be better ?

Hi! I will need to make everything above torso to move in aim direction in my game In-Dome to gain the correct aiming visual. IK-ing chest or torso bone would be resolvement, but - it would automaticly face to my aim direction which is not what I need. I need it to aim forward, while torso bone should be facing almost upward. How to do this? Also, what happens when I need different IKs? For example, for aiming I need one IK(in torso) which is described in first part, but if I want it to collect item by tracking it’s hand to item, it will require me to have second IK setup. How to use this? I expect it to require python, but I will do most of logic in python anyway…