Page 2 of 3
Re: A little question
Posted: Sat Jul 12, 2008 10:44 am
by Lynkyn
That's good, but it move my camara too much and only right-left....I would like something like the metalhead one but random left-right-up-down....Is it possible?
Re: A little question
Posted: Sat Jul 12, 2008 11:31 pm
by Juutis
Code: Select all
RotateEntity("Player",0,random(-10,10),0);
Rotates the camera to the left and right. Just decrease the values in 'random(-10,10)' to make it rotate less.
For the up/down issue try this:
Code: Select all
TiltCamera((random(-10,10) + 0.0)/100);
(random() returns an integer and adding 0.0 changes it into a float, which can then be divided)
Again, you can change the values of 'random(-10,10)' to make it tilt just the way you want.
Re: A little question
Posted: Sun Jul 13, 2008 2:05 pm
by Lynkyn
Re: A little question
Posted: Sun Jul 13, 2008 8:03 pm
by metal_head
Yeah,I forgot to mention that I edited the script (of course wih Juutis help
) so that the camera tilts only upwards.
Re: A little question
Posted: Fri Jul 18, 2008 5:42 pm
by Lynkyn
Oooh, OK, now i've got a little problem: when the cameratilt is little, it looks good, but when it's big, it's too sudden. I would want to know if there is any script to ''soft'' this effect. Thanks
Re: A little question
Posted: Fri Jul 18, 2008 6:48 pm
by metal_head
You want to make the amera tilt sommth,right?...Well,I have no idea how to make it
:D:D:D:D after all,I'm a newbie and the game I'm making is my first one.I just made the camera very very little,so it doesn't look so rough
Re: A little question
Posted: Fri Jul 18, 2008 7:01 pm
by Juutis
Try this one:
Code: Select all
{
tilttimer [0]
tiltamount [0]
rotateamount [0]
lastbullets [0]
Spawn[ ()
{
LowLevel("run");
} ]
run[ ()
{
self.ThinkTime = 0.04;
if(GetAttribute("bullets","Player") < lastbullets)
{
tilttimer = self.time + 0.5;
tiltamount = (random(-10,10) + 0.0)/100;
rotateamount = random(-10,10);
lastbullets = GetAttribute("bullets","Player");
}
if(tilttimer > self.time)
{
RotateEntity("Player",0,rotateamount,0);
TiltCamera(tiltamount);
}
if(GetAttribute("bullets","Player") > lastbullets)
{
lastbullets = GetAttribute("bullets","Player"); //update 'lastbullets' if the player receives more bullets
}
} ]
}
You can play around with the values of tilttimer, rotateamount and tiltamount to get it just like you want. tilttimer controls the time in seconds that the tilting should last. In this example it last 0.5 seconds. tiltamount and rotateamount control how fast the camera will tilt.
Re: A little question
Posted: Fri Jul 18, 2008 7:13 pm
by Lynkyn
You are a genious O_O
Thanks! Hope i will give you a reward for this
Re: A little question
Posted: Sat Jul 19, 2008 9:18 am
by metal_head
WoW,I can't wait to try this one!!!When I get back home on monday,I'll take a look.If I understand right from the script,there's a time ammount which is used when the camera is being tilt.
Re: A little question
Posted: Wed Jul 23, 2008 11:34 am
by Lynkyn
Little problem: the min. value I can put in the tilt and rotate is 1. y I put 0.8, 0.2, it doesn't work. Why?
Re: A little question
Posted: Thu Jul 24, 2008 9:17 am
by Graywolf
I'd bet(I'm at a friends house at the moment, otherwise I'd check the source) that the random command is converting the values to integers(thus, 0). You could try dividing the results. Say... 1.3 for the rotate, 150 or so for the tilt(instead of 100).
Re: A little question
Posted: Thu Jul 24, 2008 9:37 am
by QuestOfDreams
Manual:
int random(float Low, float High);
Returns a random integer number in the range of Low to High.
Re: A little question
Posted: Thu Jul 24, 2008 4:14 pm
by Lynkyn
In the tilit I can put, for example,
tiltamount = (random(-1,0) + 0.0)/200;
but, in the rotate?
rotateamount = random(-1,1);
Thanks
Re: A little question
Posted: Fri Jul 25, 2008 2:43 pm
by Graywolf
Code: Select all
RotateEntity("Player",0,rotateamount * 0.8,0);
That would work, although it would be better practice to add a variable to the script, like so:
Code: Select all
{
tilttimer [0]
tiltamount [0]
rotateamount [0]
rotatefactor [0.8]
lastbullets [0]
Then:
Code: Select all
rotateamount = random(-10,10) * rotatefactor;
In fact, if you use variables for all the values, you'll be in prime position to add code to change the camera shake effect for different weapons.
Juutis wrote:(random() returns an integer and adding 0.0 changes it into a float, which can then be divided)
This can also be done in a more visible fashion, using:
Code: Select all
rotateamount = toFloat(random(-10,10))/100;
This has the added benefit of preserving the original value in integer form... Which has it's uses(although I can't think of one in this context).
Re: A little question
Posted: Mon Jul 28, 2008 11:13 am
by Lynkyn