Camera help anyone?

Posted By: Sleepy

Camera help anyone? - 03/07/14 20:22

I found this code online somewhere sometime in the past, It works great all but camera tilt. Can someone help please?
Code:
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);
}
}

Posted By: Superku

Re: Camera help anyone? - 03/08/14 00:06

I'm sorry but I don't think that post will get you a ton of answers. You didn't really state your problem clearly nor is anyone eager to work through foreign code (and it's almost unreadable without [code ] tags).
If the camera.tilt is your problem I would check the corresponding line of code:

camera.tilt = player.tilt; //5 * mouse_force.y * time_step;
Posted By: Sleepy

Re: Camera help anyone? - 03/08/14 12:48

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.
Posted By: Superku

Re: Camera help anyone? - 03/08/14 12:58

Quote:
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.
Posted By: Kartoffel

Re: Camera help anyone? - 03/08/14 15:14

I have to agree with Superku...

And even though I shouldn't do this...
Here's your code:

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.
Posted By: FoxHound

Re: Camera help anyone? - 03/10/14 21:47

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."
Posted By: rayp

Re: Camera help anyone? - 03/11/14 08:09

Did not read much here except the title, just wanted to say, if its only up to cam handling scripts: here some:

http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=429503#Post429503
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=437532#Post437532

Some scripts to learn from, pretty good to start with:
http://www.rp-interactive.nl/ws/wshops.html

btw: Please use code tags, Sleepy

Greets
© 2024 lite-C Forums