2 registered members (AndrewAMD, Ayumi),
1,405
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Camera help anyone?
#438121
03/07/14 20:22
03/07/14 20:22
|
Joined: Jan 2006
Posts: 21
Sleepy
OP
Newbie
|
OP
Newbie
Joined: Jan 2006
Posts: 21
|
I found this code online somewhere sometime in the past, It works great all but camera tilt. Can someone help please?
action players_code() // attach this action to your player model in all the levels
{
var movement_speed = 10; // movement speed
VECTOR temp;
set (my, INVISIBLE); // 1st person player
player = my; // I'm the player
// this section recreates the flashlight (if needed)
if (got_flashlight == 1) // the flashlight was picked up in a previous level?
{
flashlight = ent_create("lantern.mdl", player.x, move_flashlight); // the recreate it!
}
// end of the section that recreates the flashlight (if needed)
while (1)
{
my.pan -= 7 * mouse_force.x * time_step;
player.tilt += 5 * mouse_force.y * time_step;// Added this line but doesn't work.
camera.x = my.x;
camera.y = my.y;
camera.z = my.z + 50 + 1.1 * sin(my.skill44); // play with 50 and 1.1
camera.pan = my.pan;
camera.tilt = player.tilt; //5 * mouse_force.y * time_step;
vec_set (temp.x, my.x); // trace 10,000 quants below the player
temp.z -= 10000;
temp.z = -c_trace (my.x, temp.x, IGNORE_ME | IGNORE_PASSABLE | USE_BOX) - 2; // play with 2
temp.x = movement_speed * (key_w - key_s) * time_step;
temp.y = movement_speed * (key_a - key_d) * 0.6 * time_step;
c_move (my, temp.x, nullvector, IGNORE_PASSABLE | GLIDE);
wait (1);
}
}
Last edited by rayp; 03/11/14 08:10. Reason: added code tags
|
|
|
Re: Camera help anyone?
[Re: Superku]
#438138
03/08/14 12:48
03/08/14 12:48
|
Joined: Jan 2006
Posts: 21
Sleepy
OP
Newbie
|
OP
Newbie
Joined: Jan 2006
Posts: 21
|
Ok, first off I guess you didn't notice the Newbie under my name, nor the first line of the post that STATES that the problem is in the tilt. (Wait you must have, you pointed me to that line.)
I took your advice and cleaned it up a bit, but, as a newbie the only way I know to post a code on here is to copy paste. Sorry it crams it all together that way.
Second, I already knew it was in the line that you pointed me to. That's why I have the line above it commented;
player.tilt += 5 * mouse_force.y * time_step;// Added this line but doesn't work...
The line that you poined me to. camera.tilt = player.tilt; //5 * mouse_force.y * time_step;
All I can say is that the software claims it can be used by ANYONE, without programming experience. I am here to tell you that it is possible but the game will suck and will never go anywhere but your desktop.
No this isn't the first time I have asked for help in the forums. No this isn't the first time I have been given a short answer by an expert that really doesn't help my problem, just points at the problem and laughs.
Again I am a NEWBIE, The camera will NOT TILT!
Sorry if I seem rather rude, but again, not the first time I have asked for help on a forum that claims it offers help to the new users and have got the same type of response.
May I suggest that before someone responds to a post, check the level of the user and respond in kind.
As for searching through foreign code to help someone. What happens when someone needs help with a template that is packaged with the software? That's foreign code..
I see post like this all over the forums. It isn't just my post. It is post like this that make me want to move on to another software.
Again sorry for seeming rude but it does get a bit discouraging.
|
|
|
Re: Camera help anyone?
[Re: Sleepy]
#438139
03/08/14 12:58
03/08/14 12:58
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
Sorry if I seem rather rude You are. Btw. you do not need to know anything about coding, just apply common sense. You want to change camera.tilt? Then why not change it, the relevant part/ what you need to add has already been commented out: camera.tilt = camera.tilt - 5 * mouse_force.y * time_step; or camera.tilt -= 5 * mouse_force.y * time_step; You could or should clamp that value, too: camera.tilt -= 5 * mouse_force.y * time_step; camera.tilt = clamp(camera.tilt,-85,85); // you can try other values lower than 90, too or camera.tilt = clamp(camera.tilt-5 * mouse_force.y * time_step,-85,85); Finally, player.tilt normally should remain unchanged in a movement code. EDIT: Btw. your number of posts or the title below your name does not mean anything. If you want to create games don't expect that you get away with "I'm a newbie/ non-coder", that's bullsh*t, don't even start with it. Do what you are capable of, ask politely and PRECISELY what you don't know and what's crucial, learn from it. Do not keep a non-coder attitude, it will not bring you very far.
Last edited by Superku; 03/08/14 13:02.
"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual Check out my new game: Pogostuck: Rage With Your Friends
|
|
|
Re: Camera help anyone?
[Re: Superku]
#438144
03/08/14 15:14
03/08/14 15:14
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
I have to agree with Superku... And even though I shouldn't do this... Here's your code:
action players_code() // attach this action to your player model in all the levels
{
var movement_speed = 10; // movement speed
VECTOR temp;
set(me, INVISIBLE); // 1st person player
player = me; // I'm the player
// this section recreates the flashlight (if needed)
if (got_flashlight == 1) // the flashlight was picked up in a previous level?
{
flashlight = ent_create("lantern.mdl", player.x, move_flashlight); // the recreate it!
}
// end of the section that recreates the flashlight (if needed)
while (1)
{
my.pan -= mickey.x * time_step;
//
camera.x = my.x;
camera.y = my.y;
camera.z = my.z + 50 + 1.1 * sin(my.skill44); // play with 50 and 1.1
camera.pan = my.pan;
camera.tilt -= mickey.y * time_step;
camera.tilt = clamp(camera.tilt, -90, 90); // keep angle beetween -90° and 90°
//
vec_set(temp.x, my.x); // trace 10,000 quants below the player
temp.z -= 10000;
temp.z = -c_trace(my.x, temp.x, IGNORE_ME | IGNORE_PASSABLE | USE_BOX) - 2; // play with 2
temp.x = movement_speed * (key_w - key_s) * time_step;
temp.y = movement_speed * (key_a - key_d) * 0.6 * time_step;
c_move(my, temp.x, nullvector, IGNORE_PASSABLE | GLIDE);
wait (1);
}
}
I've replaced mouse_force with mickey, since mouse_force is clamped to a range of [-1 ... 1] Also I'm using clamp to keep tilt between -90 and 90 degrees. But please do us all the favor and try to understand what it's doing, NOW. If you have trouble understanding it, please ask but don't think I'm going to write more stuff for you.
Last edited by Kartoffel; 03/08/14 15:29. Reason: typos everywhere
POTATO-MAN saves the day! - Random
|
|
|
Re: Camera help anyone?
[Re: Kartoffel]
#438243
03/10/14 21:47
03/10/14 21:47
|
Joined: Jun 2004
Posts: 2,234 Wisconsin USA
FoxHound
Expert
|
Expert
Joined: Jun 2004
Posts: 2,234
Wisconsin USA
|
There are templates to be used if you want to do it without experience. Otherwise you will need to learn to code or at least learn how to describe your actual problem.
Your main problem here is you think -5 is a lot of tilt, when actually it is very little.
Next is is normal to tell "Newbies" that they did not describe their problem very well or their want in their code, when almost always the post begins with "it doesn't do what I want even though I haven't told it to do what I want to do."
--------------------- There is no signature here.
QUIT LOOKING FOR ONE!
|
|
|
|