3rd person rotation...again

Hi

I’ve posted this question before, but I haven’t had time to tinker with it until recently and I’m still experiencing Blender brain freeze.

I’m trying to modify Social’s FPS Template for third person. What I’m having trouble with is getting the player to turn in the right direction on the x and y axis when movement keys are pressed. By the “right direction” I mean if a movement key is pressed, say the “forward” key, the character will turn to face away from the camera (which is controlled by the mouse). For the “left” key the character will turn to face to the left side of the camera frame, etc. How far a character needs to rotate when he begins moving is based on three things: the character’s current orientation, the orientation of the camera, and which directional key is pressed (left, right, back, forward).

I was able to find a solution using getOrientation and setOrientation but it results in instant rotation. I need a method (probably using an IPO?) that will cause “slow” rotation. Does anyone have any suggestions?

You can download the file so far without any character rotation here.

WASD to move.
Move mouse to control camera.

Also, as a side question, you’ll notice in the download that the character animation often get screwed up and “sticks” on the first frame of the run animation rather than playing the “rest” animation when the character is not in motion. Can someone inspect my code and tell me why this is happening?

Thanks for your help.

Oh, there is a file I tried about weeks ago, that had what you wanted. I think if was from this forum. Someone game demo.

After press play, the camera move in to watch a tiny little monkey on a building. With the buttons, you control the monkey, including some interesting jumping and spinning animations. The camera follows the monkey around the building etc.

Perhaps do a search here for something with monkey in it? Until some guru comes by to help you out.

I am downloading the file to look at it, but will be busy till friday even. So hopefully you will have the anwer before then.

Is this the file your talking about? The link is expired. If you happen to still have the file could you post a link to it?

Thanks.

Yes, I found it on my drive, and its called monkey.blend

so its p00fs file. He is havng trouble with his site…too many hits. I will post it for you ok>>>>

I will try to get it up tonight…

Its here. Hope that helps you… will check back tom evening

No, in that .blend the character is rotated manually and the camera just follows it on a set path I think. What I’m trying to do is very different, let me try to explain more fully.

The camera in my setup (actually a modified version of Social’s FPS Template) orbits around a center-point in the player’s head 360 degrees in every direction, and is controlled by mouse movement. Rotating the view of the camera does not rotate the player.

What I need is a method to ascertain which direction the camera is facing in the x and y axis (or more simply the 2d rotation of an object the camera is parented to). When one of the movement keys is pressed the player should turn (not be instantaneously rotated) from whatever his current orientation is towards that direction relative to the camera.

For instance:

Forward key - causes the player to turn from whatever direction he is facing so that he is facing away from (with his back towards) the camera.

Left key - causes the player to turn from any direction to face the left side of the camera frame, 90 degrees counter-clockwise from the forward direction.

Right key - turn to face right side of camera frame.

Back key - turn to face towards the camera.

Thanks for trying ititrx (the monkey was still pretty cool).

Hopefully someone has seen or done something like this before and can help.

Ok, I understand…and will give it some thought. Sorry my mistake

Ok, I really wasnt paying attention here. Sorry. I will look at it tonight.

I’m also trying to do what you want to happen, it involves tracking to a plane which changes direction by an ipo. I’ll post what i have now in a bit. 'm having problems with cornering though. For camera movement, use the camera fallow method… i think…
i can’t remember!!!:eek:

Hi,
I think you need a couple of global vars set to the mousex and mousey vars. Then in the walk py you can compare your player/own x, y to these.

Based on the difference you can then set the direction you should face before moving off.
Then you can add new ipo acts to turn the direction you need to turn before you call:
act. setLinearVelocity

or (the easiest) add a motion drot act to rotate instead of an ipo, and then move off with the setLinearVelocity

Hope that helps. I see what you are talking about with the rest/run. I will play with that and get back to you.

The run/rest works every other time, and at the start, rest is not running… so just add a new always sensor for viewer ->AND-> the REST actuator.

He’s cute, like his feet/ear movements. Smile.

Years ago, my Aunt took care of one of these guys from africa. He did not survive. But he was the sweetest creature. He always wanted to be carried and would use those long claws to climb up your pants leg. ANd it had the longest tongue. It would lick you neck, and ears and tickle you.

edit later in day:
LOL, ok I give up on this, sorry. I just dont know enough python and how these things react to each other. I tried about 4 different notions and none worked.

I tried, ray sensors, and collision detection, etc. Although I did not try to set the veiwer directly.

OH, and I combined the aim and walk script for simplicity allowing all the vars to be available.

Perhaps Social could work on this if you asked him?

Thanks for trying so hard! I too have banged at this for a few days and have made little progress. Anyone with mad Python skillz want to give it a try? Social, I’m looking at you…

Thanks.

I think i got it sort of working http://www.savefile.com/files/813226

makaveli, when I move my mouse the camera spinds wildly around the character, maybe its just my sensitive tablet mouse, hm

Yeah its really sensitive :frowning: , it works okay for me as im using a mouse.

My method isn’t great as its just - character track to empty and the empty is parented to the camera, if you increase the time on the track to actuator it makes it a little less sensitive.
Sorry im tired so im probably not making any sense.

Thanks makaveli but I am looking for a method that doesn’t rotate the character with the camera - instead the camera should move independently of the player rotation and the player should rotate to the correct position only when a movement key is pressed.

If you remember the movement and camera setup from Mario 64, what I am talking about it very similar except that I’d like the camera in my setup to be completely free moving (in Mario 64 you just had a certain number of environmentally dictated angles to choose from at any given moment). You could rotate the view but Mario wouldn’t turn until you told him to walk. Then he would turn in the direction you told him to walk relative to where the camera is.

This problem is almost as challenging to explain properly as it is to solve. :slight_smile:

Do you understand?

Thanks for all your efforts though. Please don’t give up on me!

Bye

I think I might be able to whip together a non-python example, this is a placeholder.

If you could do it with python and less random logic than my method, that would probably be better, but I believe mine should work

[edit] okay, I made the example. It’s probably not the most efficient method, but it works.

clicky -> link <- clicky

Ah, michaelwakka i will go and play Mario 64 on the DS to see what you mean.
Michael yor 3rd person template has helped me make progress in the over the shoulder camera view like Gears of War :evilgrin:, thanks.

Hmm, well I used the mouse look .blend file and just changed the slide left and right to rotate left and right on the Z axis.

So, the character will always have its back to the camera, as you said you wanted it, and you can turn and look left and right with the character, and the mouse can look around in circles.

But I would think you already have that script because it is similar to the aim script you are using?

Anyway it is here:
http://www.tutorialsforblender3d.com/MouseLook/MouseLook_3_Tutorial.html

you just need to click on the finished scene and change the dloc to drot on the Z axis, the last box of the logic bricks.

Thanks makaveli but I am looking for a method that doesn’t rotate the character with the camera - instead the camera should move independently of the player rotation and the player should rotate to the correct position only when a movement key is pressed.

What the heck? You said you wanted it to keep its back to the camera… unless it turns… oh well, I give up, LOL.

Very nice. Now I understand what he was after.

Look at some of the demos from the link in this thread. See the first post by “ineedanewbi”.

Hope this helps.

honeycomb

What we’re using for the Monkey Game Project (possibly) is this:

  • The main object has two empties, one for the x axis rotation and one for the y. The “y” empty is parented to the “x” empty.
  • Another empty is parented to the “x” empty and is placed out in front of the main object.
  • When the WSAD keys are pressed, the main object tracks (not 3D tracking) to the empty out front.

What this means is that the empty is rotated around with the camera without rotating the main object. When you press WSAD, the object will turn towards that empty.

To modify it slightly for your purposes, just have four ipo keys for the empty. If you press W, it is placed out front, if you press S, it is placed behind, ect.

That would give you the desired effect I believe. I would give you the file but we don’t want to release anything from our game yet. Hope that helps!

~~Stu