A little question
A little question
How can I do that when I'm shotting, the camera moves? (I was thinking about a random) I answer this on the spanish forum, but no one knows how to do it.
But it must be something like this:
{
If (GetAttribute(''xweapon'') != 1) and (GetAttribute("xbullets") != >0) and (IsKeyDown(72))
{
self.camera_pitch + 45 }////////I want to do a random but I dont know how
}
I don't know scripting, but I think to put a Pawn camera and associate it this Script...
Can you give me some help?
Thanks and excuse me for the mistakes
But it must be something like this:
{
If (GetAttribute(''xweapon'') != 1) and (GetAttribute("xbullets") != >0) and (IsKeyDown(72))
{
self.camera_pitch + 45 }////////I want to do a random but I dont know how
}
I don't know scripting, but I think to put a Pawn camera and associate it this Script...
Can you give me some help?
Thanks and excuse me for the mistakes
Re: A little question
Fairly simple: First make the pawn detect if a weapon has been fired. The easiest way would be to look at the bullets and if they decrease, the gun must've been fired. Then you can use the TiltCamera() and RotateEntity() to rotate the camera. So, the script:
Something like this should work. 'lastbullets' is a variable that you need to add in the beginning of the script. It holds the last amount of ammo that the pawn knows. Then if the actual amount of ammo (the attribute) changes, the pawn's variable doesn't and the pawn can see if the ammo has decreased or increased. If it decreases it rotates the player and tilts the camera. If it increases it updates the variable so it keeps up with the attribute.
Code: Select all
if(GetAttribute("bullets","Player") < lastbullets) //if bullets have decreased since last update
{
RotateEntity("Player",0,random(-10,10),0); //only rotate around Y-axis
TiltCamera(random(-10,10)/100); //tilt the camera. must be a very small value
lastbullets = GetAttribute("bullets","Player"); //update 'lastbullets'
}
if(GetAttribute("bullets","Player") > lastbullets)
{
lastbullets = GetAttribute("bullets","Player"); //update 'lastbullets' if the player receives more bullets
}
Pain is only psychological.
- metal_head
- Posts: 1244
- Joined: Sat Jan 05, 2008 8:31 pm
- Location: Bulgaria,Sofia
- Contact:
Re: A little question
Is that for a scripted player,or it can be used on the default player,by putting an invisible pan holding this script?
Re: A little question
It works with the built-in player. May work with a scripted player too, depending on how it is scripted.
Pain is only psychological.
- metal_head
- Posts: 1244
- Joined: Sat Jan 05, 2008 8:31 pm
- Location: Bulgaria,Sofia
- Contact:
Re: A little question
So if I want to get it working with the built in player,the script should look like this:
lastbullets [0]
bullets [0]
right? or I'm making a mistake(I'm sure about that).Sorry that I'm interfeering,but I would like something like that in my game too.
lastbullets [0]
bullets [0]
Code: Select all
Spawn[ ()
{
if(GetAttribute("bullets","Player") < lastbullets) //if bullets have decreased since last update
{
RotateEntity("Player",0,random(-10,10),0); //only rotate around Y-axis
TiltCamera(random(-10,10)/100); //tilt the camera. must be a very small value
lastbullets = GetAttribute("bullets","Player"); //update 'lastbullets'
}
if(GetAttribute("bullets","Player") > lastbullets)
{
lastbullets = GetAttribute("bullets","Player"); //update 'lastbullets' if the player receives more bullets
}
Return();
}]
Re: A little question
You'd have to execute that in low level. And you might want to hide the pawn etc. So the script would be:
Also, no need for the variable 'bullets'. bullets is a player attribute and lastbullets is a variable.
Code: Select all
{
lastbullets [0]
Spawn[ ()
{
PawnRender(false);
LowLevel("run");
}
run[ ()
{
self.ThinkTime = 0.1;
if(GetAttribute("bullets","Player") < lastbullets) //if bullets have decreased since last update
{
RotateEntity("Player",0,random(-10,10),0); //only rotate around Y-axis
TiltCamera(random(-10,10)/100); //tilt the camera. must be a very small value
lastbullets = GetAttribute("bullets","Player"); //update 'lastbullets'
}
if(GetAttribute("bullets","Player") > lastbullets)
{
lastbullets = GetAttribute("bullets","Player"); //update 'lastbullets' if the player receives more bullets
}
}
}
Pain is only psychological.
- metal_head
- Posts: 1244
- Joined: Sat Jan 05, 2008 8:31 pm
- Location: Bulgaria,Sofia
- Contact:
Re: A little question
I changed the attribute from "bullets" to "pistol_shell",but when I tested the script,it didn't work.I put a Console(true); so I can see where's the problem,but the console didn't show up either. What can I be doing wrong?
Re: A little question
Oh, sorry. My bad. The orders are missing ] from the end.
Code: Select all
{
lastbullets [0]
Spawn[ ()
{
PawnRender(false);
LowLevel("run");
} ]
run[ ()
{
self.ThinkTime = 0.1;
if(GetAttribute("bullets","Player") < lastbullets) //if bullets have decreased since last update
{
RotateEntity("Player",0,random(-10,10),0); //only rotate around Y-axis
TiltCamera(random(-10,10)/100); //tilt the camera. must be a very small value
lastbullets = GetAttribute("bullets","Player"); //update 'lastbullets'
}
if(GetAttribute("bullets","Player") > lastbullets)
{
lastbullets = GetAttribute("bullets","Player"); //update 'lastbullets' if the player receives more bullets
}
} ]
}
Pain is only psychological.
- metal_head
- Posts: 1244
- Joined: Sat Jan 05, 2008 8:31 pm
- Location: Bulgaria,Sofia
- Contact:
Re: A little question
Thanks a lot again,I just removed the PawnRender(false); because the console sait PawnRender method not found or something like that.
I'm thinking of putting you like a programmer in my game's credits (If you agree of course)
Just one more question:
I made a small modification in the script,actually I made it more simple:
what shoul I do to make the camera tilt upwards,because after my modiffication I made it tilt left,but I want it to tilt upwards.
I'm thinking of putting you like a programmer in my game's credits (If you agree of course)
Just one more question:
I made a small modification in the script,actually I made it more simple:
Code: Select all
RotateEntity("Player",0,3,0); //only rotate around Y-axis
TiltCamera(0,10/100);
what shoul I do to make the camera tilt upwards,because after my modiffication I made it tilt left,but I want it to tilt upwards.
Re: A little question
RotateEntity() tilts the camera to the left and right. TiltCamera up and down.
TiltCamera() takes only one parameter. So it should be TiltCamera(10/100); [= TiltCamera(0.1);], not TiltCamera(0,10/100);. And if I remember correctly negative values tilt the camera upwards. Not sure about that though.
TiltCamera() takes only one parameter. So it should be TiltCamera(10/100); [= TiltCamera(0.1);], not TiltCamera(0,10/100);. And if I remember correctly negative values tilt the camera upwards. Not sure about that though.
Pain is only psychological.
- metal_head
- Posts: 1244
- Joined: Sat Jan 05, 2008 8:31 pm
- Location: Bulgaria,Sofia
- Contact:
Re: A little question
Thanks,everything is now ok!
Re: A little question
Really thanks you!
but, maybe because I dont speak right english, maybe because I am a noob with scripts, i have another question:
If I want the script run, i must to put this?:
Pawn:
PawnType: camera (???? this is my question#1)
Scriptname: arma.s (this is the name of the script)
Spawnorder: ??? (this is my question#2 XD)
Thanks again
but, maybe because I dont speak right english, maybe because I am a noob with scripts, i have another question:
If I want the script run, i must to put this?:
Pawn:
PawnType: camera (???? this is my question#1)
Scriptname: arma.s (this is the name of the script)
Spawnorder: ??? (this is my question#2 XD)
Thanks again
- metal_head
- Posts: 1244
- Joined: Sat Jan 05, 2008 8:31 pm
- Location: Bulgaria,Sofia
- Contact:
Re: A little question
PawnType - name of the pawn which will hold the script (mine is dinosaur) yes,I put a dinosaur to hold the script,little stupid...
ScriptName - the name of the script(mine is "cameratilt.s")
SpawnOrder - Spawn
I've uploaded the script,download this one and put it like that in the level and you'll see that when you shoot with the 10mm_shell,the camera will tilt up
Translated to spanish:
PawnType - nombre del peón que celebrará el script (el mío es de dinosaurio): D sí, me puso un dinosaurio para celebrar el guión, poco estúpido ...
ScriptName - el nombre del script (el mío es "cameratilt.s")
SpawnOrder - Spawn
He subido el guión, descargue éste y ponerlo al igual que en el nivel y verás que cuando se disparan con la 10mm_shell, la cámara se incline hasta
ScriptName - the name of the script(mine is "cameratilt.s")
SpawnOrder - Spawn
I've uploaded the script,download this one and put it like that in the level and you'll see that when you shoot with the 10mm_shell,the camera will tilt up
Translated to spanish:
PawnType - nombre del peón que celebrará el script (el mío es de dinosaurio): D sí, me puso un dinosaurio para celebrar el guión, poco estúpido ...
ScriptName - el nombre del script (el mío es "cameratilt.s")
SpawnOrder - Spawn
He subido el guión, descargue éste y ponerlo al igual que en el nivel y verás que cuando se disparan con la 10mm_shell, la cámara se incline hasta
- Attachments
-
- cameratilt.rar
- (429 Bytes) Downloaded 63 times
Re: A little question
Thanks, I will change 10mm_shell for 9mm (one of my ammunitions) and try
EDIT it doesn't work. But its because I dont understand really what I must to write on Pawn Type dinosaur? camera? XDDDDDD
EDIT2 YEEEEEEEAH IT WORKS!! I push camera on Pawn Type and It's works! but, always the camera goes a little up.... what i must to write to do a random (left, right, up, down)
THANKS YOU VERY VERY VERY MUCH
EDIT it doesn't work. But its because I dont understand really what I must to write on Pawn Type dinosaur? camera? XDDDDDD
EDIT2 YEEEEEEEAH IT WORKS!! I push camera on Pawn Type and It's works! but, always the camera goes a little up.... what i must to write to do a random (left, right, up, down)
THANKS YOU VERY VERY VERY MUCH
Re: A little question
Use my version of the script. metal_head removed the random() functions in his version.Lynkyn wrote:EDIT2 YEEEEEEEAH IT WORKS!! I push camera on Pawn Type and It's works! but, always the camera goes a little up.... what i must to write to do a random (left, right, up, down)
Code: Select all
{
lastbullets [0]
Spawn[ ()
{
LowLevel("run");
} ]
run[ ()
{
self.ThinkTime = 0.1;
if(GetAttribute("bullets","Player") < lastbullets) //if bullets have decreased since last update
{
RotateEntity("Player",0,random(-10,10),0); //only rotate around Y-axis
TiltCamera(random(-10,10)/100); //tilt the camera. must be a very small value
lastbullets = GetAttribute("bullets","Player"); //update 'lastbullets'
}
if(GetAttribute("bullets","Player") > lastbullets)
{
lastbullets = GetAttribute("bullets","Player"); //update 'lastbullets' if the player receives more bullets
}
} ]
}
Pain is only psychological.