|
|
Darn camera
#229945
10/01/08 19:50
10/01/08 19:50
|
Joined: Aug 2008
Posts: 408 mi usa
sadsack
OP
Senior Member
|
OP
Senior Member
Joined: Aug 2008
Posts: 408
mi usa
|
Hi, well i am trying to make the camera go and turn the same way as a ship. I want it to look like you (the camera) is flying the ship CODE:
////////////////////////////////////////////////////////////////////
ENTITY* ship;
function create_camera()
{
while(1) {
vec_set(camera.x+100,ship.x);///////////////////////////////////////////////////////
vec_set(camera.y,ship.y);///////////// move the camera together with the ship entity
vec_set(camera.z,ship.z);//////////////////////////////////////////////////////////
vec_set(camera.pan,ship.pan);} //turn camera with ship
wait(1);
}
action act_ship()
{
ship = me;
while(1)
{
if (key_z) {me.pan += 3*time_step;}
if (key_x) {me.pan -= 3*time_step;}
if (key_a){c_move (me,vector( -.3,0,0),nullvector,GLIDE);}
if (key_s){c_move (me,vector( .3,0,0),nullvector,GLIDE);}
wait(1);
}
}
function main()
{
video_screen = 1;
video_mode = 7;
level_load ("");
ent_create("ship.mdl", vector(0, 0, 0), act_ship);
//ent_create("ship1.mdl", vector(200, 0, 0), NULL);
}
The code does what I ask it to do untill I start to move the ship. The camera is right in the pilot set when the program start. But when you move or turn the ship, the camera does not move or turns. What am I over looking????? Thank You renny
I have A7 Commercial .............. Now I just need to learn how to use it
|
|
|
Re: Darn camera
[Re: sadsack]
#229946
10/01/08 19:52
10/01/08 19:52
|
Joined: Jan 2008
Posts: 1,580
Blade280891
Serious User
|
Serious User
Joined: Jan 2008
Posts: 1,580
|
Your not running the camera code, you need to call the function?
My Avatar Randomness V2"Someone get me to the doctor, and someone call the nurse And someone buy me roses, and someone burned the church"
|
|
|
Re: Darn camera
[Re: Blade280891]
#229949
10/01/08 20:11
10/01/08 20:11
|
Joined: Aug 2008
Posts: 408 mi usa
sadsack
OP
Senior Member
|
OP
Senior Member
Joined: Aug 2008
Posts: 408
mi usa
|
Now are you telling me that the program run this while loop one time and never comes back to it
while(1) {
vec_set(camera.x+100,ship.x);///////////////////////////////////
vec_set(camera.y,ship.y);///////////// move the camera together with the ship
vec_set(camera.z,ship.z);///////////////////////////////////////////
vec_set(camera.pan,ship.pan);} //turn camera with ship
wait(1);
but it keep coming back to this while loop.
action act_ship()
{
ship = me;
while(1)
{
if (key_z) {me.pan += 3*time_step;}
if (key_x) {me.pan -= 3*time_step;}
if (key_a){c_move (me,vector( -.3,0,0),nullvector,GLIDE);}
if (key_s){c_move (me,vector( .3,0,0),nullvector,GLIDE);}
wait(1);
}
}
Now why would it keep running one while loop and not the other? how would one call that function? I have asked that more than one time here and no one has told me. I tryed to do it like it show on the C book but lite-c does not like that. I get an error. Thank You renny
I have A7 Commercial .............. Now I just need to learn how to use it
|
|
|
Re: Darn camera
[Re: sadsack]
#229952
10/01/08 20:21
10/01/08 20:21
|
Joined: Jan 2008
Posts: 1,580
Blade280891
Serious User
|
Serious User
Joined: Jan 2008
Posts: 1,580
|
It looks like it doesn't run the function at all, and to call a function you would just do function();
My Avatar Randomness V2"Someone get me to the doctor, and someone call the nurse And someone buy me roses, and someone burned the church"
|
|
|
Re: Darn camera
[Re: Blade280891]
#229957
10/01/08 20:41
10/01/08 20:41
|
Joined: Aug 2008
Posts: 408 mi usa
sadsack
OP
Senior Member
|
OP
Senior Member
Joined: Aug 2008
Posts: 408
mi usa
|
Well Blade, you are right, that function does not do a dam thing. I put all the code in to
action act_ship()
{
ship = me;
while(1)
{
if (key_z) {me.pan += 3*time_step;}
if (key_x) {me.pan -= 3*time_step;}
if (key_a){c_move (me,vector( -.3,0,0),nullvector,GLIDE);}
if (key_s){c_move (me,vector( .3,0,0),nullvector,GLIDE);}
wait(1);
vec_set(camera.x+100,ship.x);///////////////////////////////////
vec_set(camera.y,ship.y);///////////// move the camera together with the ship
vec_set(camera.z,ship.z);///////////////////////////////////////////
vec_set(camera.pan,ship.pan);} //turn camera with ship
wait(1);
}
}
and it works fine. Thanks renny
I have A7 Commercial .............. Now I just need to learn how to use it
|
|
|
Re: Darn camera
[Re: sadsack]
#229974
10/01/08 22:25
10/01/08 22:25
|
Joined: Jul 2002
Posts: 3,208 Germany
Error014
Expert
|
Expert
Joined: Jul 2002
Posts: 3,208
Germany
|
A camera thread.  Not... another... camera thread :((( This is like you're calling me, personally, at like 2 AM. You're throwing rocks at my window, and when I go to look, you spit in my face, and then, you proceed to burn my house. When I'm on fire, screaming in horrible pain, running around, desperately calling for help, you run me over with a truck, and then, you blow said truck up. As you can see, I probably need psychological advice, and quick. But no, I'm going to forfeit my own sanity, safety, and life quality, all in my noble, yet ignored, quest to improve the code of others. So normally, I would now write a long post about your code and certain problems that it has, but then I noticed I didn't understand. Mind you, I don't understand lots of things, and some may say that you're in good company, but...
i am trying to make the camera go and turn the same way as a ship. I want it to look like you (the camera) is flying the ship Do you want a first person or a third person camera? Whatever the case may be, it seems like you're a bit confused about vectors. The "vec_"-part of the instructions. Vectors are, to but it simply, arrows, but it's not like the truth isn't out there. Oh well. vec_set(camera.x,... will change camera.x, camera.y, camera.z This is because all those values TOGETHER form a VECTOR, which is the POSITION of the CAMERA. Like, an arrow from the origin, pointing to the camera? That's how you can imagine it. So you only need one instruction, really, for a first person-camera, at least as far as placing the camera goes. vec_set(camera.x,ship.x); Now, the camera is right at the same position the ship currently is, meaning where the origin is placed in MED. You can then simply rotate the camera so it looks in the same direction vec_set(camera.pan,ship.pan); Things get a bit more confusing when you want a 3rd-person camera, which is ALREADY THE CASE if you JUST MOVE THE CAMERA A LITTLE BIT OFF THE ORIGIN. Alright? Even if its one quant. For more information about the subject, you may want to see these threads. Scripting from ground upGerman, but with codeGerman, but with codeand a really long explanation in germanIt's only partly your fault, though. The forum search is far from perfect. Still.And: We really, really, really, really, really, really, really, really, really, really, really, really should post a simple solution to that problem in the FAQ-forum. Sheesh. While I'm wishing for crazy things from the beings that never listen to me, can I get a custom title? I need the illusion that I'm special. plus, I'm really not an expert
Perhaps this post will get me points for originality at least.
Check out Dungeon Deities! It's amazing and will make you happy, successful and almost certainly more attractive! It might be true!
|
|
|
Re: Darn camera
[Re: Error014]
#229975
10/01/08 22:30
10/01/08 22:30
|
Joined: Jan 2008
Posts: 1,580
Blade280891
Serious User
|
Serious User
Joined: Jan 2008
Posts: 1,580
|
 ^^
My Avatar Randomness V2"Someone get me to the doctor, and someone call the nurse And someone buy me roses, and someone burned the church"
|
|
|
Re: Darn camera
[Re: Error014]
#230112
10/02/08 21:42
10/02/08 21:42
|
Joined: Aug 2008
Posts: 408 mi usa
sadsack
OP
Senior Member
|
OP
Senior Member
Joined: Aug 2008
Posts: 408
mi usa
|
Well Error014, Are you my twin brother??? I go off like that from time to time.It is fun to do. Yes, you are right I am just learnning, had a7 for maybe a month. What I was trying( by the way the code work fine) was put me or you in the pilot seat so it look like we was flying it.
I have the same problem making people in LW9, I have never did much with art befor. I save this and the other thread and I am sure they will be a big help to me.
Now that I have you here!!!!
What is the best way to put another camera in the program and go back and forth using the same display window? Thank you for you help renny
I have A7 Commercial .............. Now I just need to learn how to use it
|
|
|
Re: Darn camera
[Re: sadsack]
#230154
10/03/08 10:41
10/03/08 10:41
|
Joined: Jul 2002
Posts: 3,208 Germany
Error014
Expert
|
Expert
Joined: Jul 2002
Posts: 3,208
Germany
|
Well Error014, Are you my twin brother? Unlikely, but you never know. Do you also have wings, three heads and are able to breathe fire? Oh, sigh, here we go again. What is the best way to put another camera in the program and go back and forth using the same display window?
So you can switch between 1st- and 3rd-person camera, huh? Well, add another variable! Make sure it can store enough values for all your crazy camera-modes. In case you're still using c-script, you'll have to waste use a var anyway*. Simply switch the values on a keypress, like so
function change_camera() {
myamazingcameravariable = (myamazingcameravariable%NumberOfCameraModes);
}
ON_C = change_camera;
What the heck is "%"? Percent? A mystical symbol that will reveal the single truth? The secret to being loved? The answer is YES, and even a bit more! You know, back in third grade, when you divided like this? 5 / 2 = 2 Rest 1 This dark segment of your past now comes back to haunt you, since modulo gives you the Rest - in this case, that'd be "1". Which is why you often see %360 in sin/cos-operations and %100 when it comes to animating, since you can simply loop 'em that way: 176/100 = 1 Rest 76 -> 176%100 = 76 719%360 = 1 Rest 359 -> 719%360 = 359 Another often used explanation to get it in the head of yours is to use the hour-system:
Say it's 8PM, so that'd be 20:00, right? How late is it in five hours? Naturally, the logical answer would be 25:00, but of course that's disgusting and wrong, the day only has 24 hours. So you say 1PM, and in your head, you just calculated (20+5)%24Now, in your camera-calculation, simply use your new variable combined with the amazing power of "if", and soon, you will rule the world!
if(myamazingcameravariable==0) {
//camera-behaviour one
}
if(myamazingcameravariable==1) {
//camera-behaviour two
}
...
Of course, that doesn't give you smooth movement between the "camera-positions" - that'd require a bit different code. *of course, in that case, there are also tricks to get by with a single "options"-variable.
Perhaps this post will get me points for originality at least.
Check out Dungeon Deities! It's amazing and will make you happy, successful and almost certainly more attractive! It might be true!
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|