A little question

Topics regarding Scripting with Reality Factory
Lynkyn
Posts: 48
Joined: Sat Jun 21, 2008 2:17 pm

Re: A little question

Post 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?
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Re: A little question

Post 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.
Pain is only psychological.
Lynkyn
Posts: 48
Joined: Sat Jun 21, 2008 2:17 pm

Re: A little question

Post by Lynkyn »

Excellent!!!I love youuu!!!! :mrgreen: :mrgreen: :mrgreen:
User avatar
metal_head
Posts: 1244
Joined: Sat Jan 05, 2008 8:31 pm
Location: Bulgaria,Sofia
Contact:

Re: A little question

Post by metal_head »

Yeah,I forgot to mention that I edited the script (of course wih Juutis help :D) so that the camera tilts only upwards.
Lynkyn
Posts: 48
Joined: Sat Jun 21, 2008 2:17 pm

Re: A little question

Post 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 :wink:
User avatar
metal_head
Posts: 1244
Joined: Sat Jan 05, 2008 8:31 pm
Location: Bulgaria,Sofia
Contact:

Re: A little question

Post 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: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 :)
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Re: A little question

Post 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.
Pain is only psychological.
Lynkyn
Posts: 48
Joined: Sat Jun 21, 2008 2:17 pm

Re: A little question

Post by Lynkyn »

You are a genious O_O
Thanks! Hope i will give you a reward for this :mrgreen:
User avatar
metal_head
Posts: 1244
Joined: Sat Jan 05, 2008 8:31 pm
Location: Bulgaria,Sofia
Contact:

Re: A little question

Post 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.
Lynkyn
Posts: 48
Joined: Sat Jun 21, 2008 2:17 pm

Re: A little question

Post 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? :(
User avatar
Graywolf
Posts: 75
Joined: Mon Apr 14, 2008 8:36 pm
Location: Anchorage, Alaska
Contact:

Re: A little question

Post 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).
"So, what's the life of a programmer like?" "...Huh? What life?!"

RF System X:
http://www.realityfactory.info/forum/vi ... f=9&t=3599
User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Re: A little question

Post by QuestOfDreams »

Manual:
int random(float Low, float High);
Returns a random integer number in the range of Low to High.
Lynkyn
Posts: 48
Joined: Sat Jun 21, 2008 2:17 pm

Re: A little question

Post 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 :wink:
User avatar
Graywolf
Posts: 75
Joined: Mon Apr 14, 2008 8:36 pm
Location: Anchorage, Alaska
Contact:

Re: A little question

Post 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).
"So, what's the life of a programmer like?" "...Huh? What life?!"

RF System X:
http://www.realityfactory.info/forum/vi ... f=9&t=3599
Lynkyn
Posts: 48
Joined: Sat Jun 21, 2008 2:17 pm

Re: A little question

Post by Lynkyn »

edit:THANKS REALLY Now it's cool!!!!! :D :D :D
Post Reply