Author |
Topic: Moving cars |
cskiller86 |
|
General Member Since: Nov 23, 2009 Posts: 528 Last: Oct 25, 2011 [view latest posts] |
|
|
Category: CoD4 MP Mapping Posted: Tuesday, Jan. 19, 2010 11:19 am |
|
Hey, I'm trying to make a street that has a few cars moving (on both lanes) using the moving brush script. But the problem is their wheels aren't rotating (no animation).
When I started my map, I placed a BMP inside and it's tracks were "moving". So I selected the BMP_static model and the tracks aren't moving anymore. So I thought that all the vehicles that have a _static in their name, also have an animated state. Unfortunately, that only works for tracked vehicles (M1A2, T72, BMP), and probably the track texture is animated through a special shader or something like that.
So I tried using jeannotvb's tutorial on moving vehicles for SP and adapting it for MP. I made a script_vehicle_mp, added nodes, trigger, set everything up with the vehicle window (SHIFT+V). The problem is that I have to add _uaz.gsc to the zone file, which calls on other .gsc files, and in the end this file is called
Code: animscripts\utility.gsc
which is nowhere to be found, so I get a script error.
But I don't think this is the right way to do it, so it doesn't really matter.
My question is: how do I make the cars' wheels to rotate ? |
|
|
|
DemonSeed |
General Member Since: Apr 30, 2009 Posts: 1362 Last: Feb 19, 2018 [view latest posts] |
|
|
|
Category: CoD4 MP Mapping Posted: Tuesday, Jan. 19, 2010 01:08 pm |
|
Well, its a considerable bit of work, but it can be done -
To get the rotating/moving effect, the textures are created in Asset Manager using a material which is a model phong, with "Texture Scroll" check marked. If you deconstruct (no reference to Jacques Derrida!) the textures used in any model, you can re-make the materials that go with it to include texture scroll which will give you the animated effect on any model, on any given texture.
As I said, this is considerable work, but is possible. It was done 4 years ago over at IWNation.com by user Regolith (who made the now-famous Xmodel Extractor). Sadly, none of the movies he made showing what can be have survived so I cant actually show you any.
|
|
|
|
techno2sl |
|
General Member Since: Aug 5, 2004 Posts: 2977 Last: Oct 14, 2010 [view latest posts] |
|
|
|
cskiller86 |
|
General Member Since: Nov 23, 2009 Posts: 528 Last: Oct 25, 2011 [view latest posts] |
|
|
Category: CoD4 MP Mapping Posted: Tuesday, Jan. 19, 2010 05:45 pm |
|
So it can't be done with animation in MP ?
@techno: killhouse in MP or SP ? I don't really remember which is the level in SP, but I remember the jeepride level (last level) and there were cars on that road (can't remember if their wheels were rotating, but surely they were, otherwise it would have been quite a bug), and the bm21's wheels were rotating (the trucks that were chasing you).
And surely that was done through animation, but it was SP.
Maybe someone who knows more about animation will read this and make a script. In the meantime, I will try to do what DemonSeed said, although I didn't understand half of it :)
Just kidding, I understood that I would have to remake the tire material for all the cars I want to use. If the texture scroll works like the threads of the tanks, then the part with the grooves on the tire will move. But what about the hub cap part, how would I make that revolve around its centre ? |
|
|
|
DemonSeed |
General Member Since: Apr 30, 2009 Posts: 1362 Last: Feb 19, 2018 [view latest posts] |
|
|
|
Category: CoD4 MP Mapping Posted: Tuesday, Jan. 19, 2010 06:02 pm |
|
Quote: Maybe someone who knows more about animation will read this and make a script.
There is no vehicle animation in MP with IW-created games. EVER! This is why people are always looking for "work-arounds" for the past 6 years. So, dont even bother trying to find one. And on one is going to write one for you, coz it cant be done. |
|
|
|
techno2sl |
|
General Member Since: Aug 5, 2004 Posts: 2977 Last: Oct 14, 2010 [view latest posts] |
|
|
|
cskiller86 |
|
General Member Since: Nov 23, 2009 Posts: 528 Last: Oct 25, 2011 [view latest posts] |
|
|
Category: CoD4 MP Mapping Posted: Sunday, Jan. 24, 2010 07:22 pm |
|
OK, so I put some barriers alongside the road so now you can't see the tires (that's my workaround)... the highway is at quite some distance and you can't get closer, so I think it will work.
I'm having a problem with the script, though.
I have 5 different car models (script_models) which travel on 2 opposite lanes. At the beginning of each lane there is a script_origin (their names are startleft and startright) which serve as starting points for the cars.
This is what I made:
Code: main()
{
car1 = getent ("car1", "targetname");
car2 = getent ("car2", "targetname");
car3 = getent ("car3", "targetname");
car4 = getent ("car4", "targetname");
car5 = getent ("car5", "targetname");
while(1)
{
activecarleft = car+randomintrange(1,6);
activecarright = car+randomintrange(1,6);
activecarleft thread leftcarmove();
activecarright thread rightcarmove();
wait 15;
}
}
leftcarmove()
{
startleft = getent ("startleft", "targetname");
self.origin = startleft.origin;
self rotateyaw(180, 0.1);
cartime = 10+randomint(5);
self movex(-2000, cartime);
wait cartime;
self rotateyaw(180, 0.1);
}
rightcarmove()
{
startright = getent ("startright", "targetname");
self.origin = startright.origin;
cartime = 10+randomint(5);
self movex(2000, cartime);
}
The line Code: activecarleft = car+randomintrange(1,6); should select a random car from those 5, but I get an error that variable car isn't initialized.
I'm not sure how to concatenate a string and an integer. Any help ?
edited on Jan. 24, 2010 02:25 pm by cskiller86 |
|
|
|
Samuel033 |
General Member Since: Dec 10, 2009 Posts: 484 Last: Dec 25, 2015 [view latest posts] |
|
|
Category: CoD4 MP Mapping Posted: Sunday, Jan. 24, 2010 08:01 pm |
|
Based on the code car isnt a string, but an unused variable. Just a thought but you might want to get a string first ("car" + some number). I'm not an experienced cod4 coder but I would think it should work.
temp = "car" + somerandomnumberstring;
activecarleft = getent (temp, "targetname");
Or just use a simple switch since there are only 5 possible cars. A switch with 5 cases for rightcar and second one for leftcar. The switch is certainly longer but more straightforward and makes it easy to add different types later. Pickup, Motorcycle etc. Just add another case.
Edit: Oooops, xholyx beat me to it
edited on Jan. 24, 2010 03:02 pm by Samuel033 |
|
|
|
xholyx |
|
General Member Since: Oct 17, 2007 Posts: 116 Last: Sep 7, 2010 [view latest posts] |
|
|
Category: CoD4 MP Mapping Posted: Sunday, Jan. 24, 2010 08:01 pm |
|
try this:
Code:
main()
{
while(1)
{
randcar = "car"+randomintrange(1,6)+"";
randcar2 = "car"+randomintrange(1,6)+"";
activecarleft = getent(randcar,"targetname");
activecarright = getent(randcar2,"targetname");
activecarleft thread leftcarmove();
activecarright thread rightcarmove();
wait 15;
}
}
leftcarmove()
{
startleft = getent ("startleft", "targetname");
self.origin = startleft.origin;
self rotateyaw(180, 0.1);
cartime = 10+randomint(5);
self movex(-2000, cartime);
wait cartime;
self rotateyaw(180, 0.1);
}
rightcarmove()
{
startright = getent ("startright", "targetname");
self.origin = startright.origin;
cartime = 10+randomint(5);
self movex(2000, cartime);
}
hehe nice one samual03 :P |
|
|
|
cskiller86 |
|
General Member Since: Nov 23, 2009 Posts: 528 Last: Oct 25, 2011 [view latest posts] |
|
|
Category: CoD4 MP Mapping Posted: Monday, Jan. 25, 2010 11:27 am |
|
Thanks for your answers.
I thought about case structure, last night while I was trying to get asleep.
It works the first way, though. The problem is when the same car gets selected at the same time, and it starts going backwards on one of the lanes. It's actually funny :)
Have to change the code a little... or to make a set of 5 cars for each lane.
edited on Jan. 25, 2010 06:52 am by cskiller86
OK, I made some changes and it works great. I added another car for when the numbers are equal.
Code: main()
{
while(1)
{
templ = "car"+randomintrange(1,6);
tempr = "car"+randomintrange(1,6);
if (templ == tempr)
tempr = "carextra";
activecarleft = getent (templ, "targetname");
activecarright = getent (tempr, "targetname");
activecarleft thread leftcarmove();
activecarright thread rightcarmove();
wait 13;
}
}
leftcarmove()
{
startleft = getent ("startleft", "targetname");
self.origin = startleft.origin;
self rotateyaw(180, 0.1);
cartime = 7+randomint(5);
self movex(-1600, cartime);
wait cartime;
self rotateyaw(180, 0.1);
}
rightcarmove()
{
startright = getent ("startright", "targetname");
self.origin = startright.origin;
cartime = 7+randomint(5);
self movex(1600, cartime);
} |
|
|
|