AttachCameraToBone() help...

Topics regarding Scripting with Reality Factory
Post Reply
NolanK
Posts: 24
Joined: Sun Aug 07, 2005 11:53 pm
Location: Canada

AttachCameraToBone() help...

Post by NolanK » Thu Aug 25, 2005 7:14 am

ok i want to use the AttachCameraToBone() command to make a scripted 3rd person player. i tried it and it seemed to work just fine (except for a bad offset of the yaw), but i noticed that i couldnt look left to right, only up and down (im VERY new to RF scripting). So i finally figured out that i had to put:

self.ideal_yaw=self.player_yaw;
ChangeYaw();

So when i go to see if my player can turn left to right, something very buggy happens. I move the mouse right, the player and camera start to turn right, then after about 70 degrees of turning, the camera starts turning left (while i keep trying to turn right), then after about 100 degrees of turning left the camera goes back to turning right :? (this is all happening when im trying to turn right with the mouse) . The camera seems to turn the other way only when im facing a certain direction.

After a while of testing, i think the problem lies in the fact that the camera was in first person mode (F1), but my scripted player was in "third person mode" (via the AttachCameraToBone() function). I think this is where the problem lies because i tried using the AttachCamera() function instead of AttachCameraToBone() and in first person mode the camera would rotate normally (which makes sense because the view was "first person", as in the eyes of the pawn). I know i should be in third person mode (F3) but the AttachCameraToBone() function doesn't seem to work in third person mode :? :cry:. Like when i use the AttachCameraToBone() function in third person mode (F3), the camera isnt attached to the the bone i specified, its just attached to the pawn like it would be if i used AttachCamera().



I guess i have a couple of questions here:

1.Does anyone know whats going on with the messed up rotation in first person mode with the AttachCameraToBone() function?

2.Does anyone know how to use the AttachCameraToBone() function in third person mode?


If anyone could help me with either of the questions it would be greatly appreciated!!
All your base are belong to us.

GD1
Posts: 413
Joined: Tue Jul 05, 2005 2:33 pm

Post by GD1 » Thu Aug 25, 2005 3:58 pm

1. yaw is inverted in first person. I had this problem while trying to make a scripted weapon system, but had no success fixing it. Pickles suggested using two pawns instead of one to fix the rotation problem, so you should probably give that a go, since he's right 99% of the time.

2. I dont know.
Check out my band
Tougher Than Fort Knox
Image

rgdyman
Posts: 84
Joined: Tue Jul 05, 2005 7:05 am

Post by rgdyman » Fri Aug 26, 2005 12:17 am

I myself havn't got to this point yet.

But I did take a look at "Sacred Druids' script, ( Thanks Pickles)

It appears that Pickles used

AttachCamera();

and

self.ideal_yaw=self.player_yaw;
ChangeYaw();

try this out and see what happens.

Keep in mind, Pickles is WAY more advanced than I am. So the script
may have alot more going on than I can see.

Ransom

Post by Ransom » Fri Aug 26, 2005 12:27 am

One criteria for the scripted player (at least Pickles' scripted player) is the LevelViewPoint (within the PlayerSetup parameters - added in editor, not script) must be set to 1.

rgdyman
Posts: 84
Joined: Tue Jul 05, 2005 7:05 am

Post by rgdyman » Fri Aug 26, 2005 11:09 pm

As for the messed up rotation thing.

I think that the player is rotating faster than the camera. So when the camera is trying to keep up with the player, the player has already
finished a full rotation then the camera is trying to adjust the angles properly.. :shock: ( I hope this is somewhat clear)

Anyway, try adjusting the self.yaw_speed up a notch ot 2.
( found in Setup[() line 52)

I put it up to 356 // 256 was the default.

This looked cleaner. But a little on the fast side of thigs. Gets ya dizzy.

NolanK
Posts: 24
Joined: Sun Aug 07, 2005 11:53 pm
Location: Canada

Post by NolanK » Sat Aug 27, 2005 6:44 am

Thanks for all the replays guys! :D:D
Pickles suggested using two pawns instead of one to fix the rotation problem, so you should probably give that a go, since he's right 99% of the time.
What exactly do you mean by two pawns?
It appears that Pickles used

AttachCamera();

and

self.ideal_yaw=self.player_yaw;
ChangeYaw();

try this out and see what happens.
Actually AttachCamera() works perfectly! The thing is though, i want to use AttachCameraToBone() for a more of a "customized" third person view, if you catch my drift. This is where im having all the problems. And yes i am using

self.ideal_yaw=self.player_yaw;
ChangeYaw();

That seems to be one of the only ways to get your scripted third person player to turn left and right with the mouse :wink: .
One criteria for the scripted player (at least Pickles' scripted player) is the LevelViewPoint (within the PlayerSetup parameters - added in editor, not script) must be set to 1.
I did this, but all it did was set the camera view to thirdperson when you first start the map. When you switch to firstperson (which is what AttachCameraToBone() uses, it still has the same problem. Thanks anyways for the reply! :D
I think that the player is rotating faster than the camera. So when the camera is trying to keep up with the player, the player has already
finished a full rotation then the camera is trying to adjust the angles properly.. Shocked ( I hope this is somewhat clear)

Anyway, try adjusting the self.yaw_speed up a notch ot 2.
( found in Setup[() line 52)

I put it up to 356 // 256 was the default.
Ya, actually the self.yaw_speed can be as high as you want because the higher the number, the faster it matches the player rotation. ie, this doesnt affect the mouse sensitivity at all ( my self.yaw_speed is 1000 :lol:). All it affects is the speed at which the pawn rotates to face the same direction as the player. The pawn will NEVER rotate faster then the player so this number can be as high as you want. So technically speeking, the self.yaw_speed should be set to something like AT LEAST 300 unless you want to have to wait for the pawn to finish rotating like a second after your finished moving the mouse :wink: . But just to be on the safe side, i tried setting the self.yaw_speed to 356 like you said, but still same problem. Thanks for the help none the less :wink: .

After some more testing, i think the problem has to do with the camera. I figured out that the pawn itself is moving exactly as it should be, but the camera isnt staying pointing at the pawn :( . To fix this problem i need a way to have the camera always face the pawn. Are there any commands that rotate the camera in a certain direction or anything? If there isnt, i think there should be some commands implemented that rotate the camera to face something, or something like that. Maybe they could be something like:

RotateCameraToBone(),
RotateCameraToPawn(),

etc, etc....

I think this would definitly solve my problem and they dont seem like they would be that hard to implement, but im no programmer so its probably harder then i think, and if it was so easy, they would probably already be implemented :? . But none the less, i think these commands would definitly solve my problem and would probably be useful for lots of other things too. Anyways, just an idea...

I think the person who i would have to ask to help me solve my problem would be pickles, but he doesnt seem to post on this forum too often :cry: .

Anyways, thanks for all the help guys! :D:D

If anybody else has any ideas or knows how to rotate the camera, any help would be great! Thanks!
All your base are belong to us.

rgdyman
Posts: 84
Joined: Tue Jul 05, 2005 7:05 am

Post by rgdyman » Sat Aug 27, 2005 3:41 pm

"but the camera isnt staying pointing at the pawn . To fix this problem i need a way to have the camera always face the pawn."


LookAtPawn(char *szEntityName, float OffsetY );

Try this.

NolanK
Posts: 24
Joined: Sun Aug 07, 2005 11:53 pm
Location: Canada

Post by NolanK » Sat Aug 27, 2005 4:51 pm

I never even knew they had that command! :wink:

I tried it and its still not working. The camera is even more messed up now :? . Im not quite sure what that command does but i dont think it affects the camera like i want it too. But thanks for the help anyways :D:D.
All your base are belong to us.

rgdyman
Posts: 84
Joined: Tue Jul 05, 2005 7:05 am

Post by rgdyman » Sat Aug 27, 2005 5:33 pm

Sorry.

I wasn't sure how that would effect it. Just a quick thought.

Have you downloaded the "Docs"?

Take a look through the "LowLevel" commands.

NolanK
Posts: 24
Joined: Sun Aug 07, 2005 11:53 pm
Location: Canada

Post by NolanK » Sun Aug 28, 2005 6:47 am

Have you downloaded the "Docs"?

Take a look through the "LowLevel" commands.
Been there, done that. :wink:
All your base are belong to us.

Post Reply