Autor Wiadomość

jp adnan54


Odpowiedzi: 3

Location: Japonia
Zawód:
Wiek: 18
#1   03-08-2017 20:30          
Hi, i would like to know how to do a animated part linked to the brake pedal (i think CorradoSKJ has made something similar on his Huayra wing)
I've tried to edit this script here: *link* but i failed..
Thanks in advance

pl Dave

NIE DO ODWOŁANIA

Odpowiedzi: 1092
http://slredline.prv.pl
Location: Polska who knows...
Zawód: n/a
Wiek: 33
#2   04-08-2017 22:39          
hey there and welcome, im not best @ java but ill try to help you out,

but 1st explain better what u want to achieve :)
Regulamin strony
Pomysły, uwagi, pomoc - zapraszam na PW

jp adnan54


Odpowiedzi: 3

Location: Japonia
Zawód:
Wiek: 18
#3   19-08-2017 08:22          
Basically i just want that a part rotate few degrees when you press the gas pedal, my idea is to do a animated MFD for my R34 Skyline

pl Dave

NIE DO ODWOŁANIA

Odpowiedzi: 1092
http://slredline.prv.pl
Location: Polska who knows...
Zawód: n/a
Wiek: 33
#4   19-08-2017 09:27          
u dont even know how is nice for me to read that some1 is still modding, awesome man, respect

show me what u tryed, i mean the java (in code tags)

ps. show also real life example
Regulamin strony
Pomysły, uwagi, pomoc - zapraszam na PW

jp adnan54


Odpowiedzi: 3

Location: Japonia
Zawód:
Wiek: 18
#5   30-08-2017 20:24          
I got this script from here some years ago. Basically, it animates a part when you click on it with the screwdriver:
package java.game.cars;
import java.game.*;
import java.game.parts.bodypart.*;
import java.util.*;
import java.util.resource.*;
 
// animate part
// 2013-09-06
// by Miran
 
public class hat_holder extends DecorativeBodyPart
{
	int animate_slot_nr = 1072;
	int animate_slot_local = 1; // cordinate system flip. Set 0 if the slot is used for attaching child part, or 1 is the slot attaching this part to the parent 
 	float animation_time = 4.0; // 4 seconds
 
 
	Vector animation_frames;
 	Thread AnimateThread;
 	float animate_last_time, animate_time_delta, animate_progress, animate_target, animate_last_progress, animate_speed;
 	int installed;
 
 	public hat_holder( int id )
 	{
 		super( id );
 		carCategory = PACKAGE; // Is visable in part bin for all cars (it isn't private car's part)
 
 		name = "VW Corrado hat holder";
 		description = "Animate by Miran THX";
 
 		value = 666; //Price
 		brand_new_prestige_value = 75.00;// Prestige

		// animation frames
		animation_frames = new Vector();
		animation_frames.addElement( new Pori( new Vector3( 0.0, 0.0, 0.0 ), new Ypr( 0.0, 0.0, 0.0 ) ) ); // pos x y z, rotation x y z
		animation_frames.addElement( new Pori( new Vector3( 0.0, -0.007, 0.033 ), new Ypr( -0.041, 0.0, 0.0 ) ) );
		animation_frames.addElement( new Pori( new Vector3( 0.283, -0.007, 0.009 ), new Ypr( -0.087, 0.0, 0.0 ) ) );
		//animation_frames.addElement( new Pori( new Vector3( 1.0, 1.0, 2.0 ), new Ypr( 3.14, 0.0, 3.14 ) ) );

		animate_speed = (float)animation_frames.size() / animation_time;
 
 		AnimateThread = new Thread( this, "Animate Thread" );
 		animate_last_time = System.simTime();
 		AnimateThread.start();
 	}
	
	public void command( String cmd )
	{
		if( cmd == "flap_toggle" ) // cursor click
		{
			if( animate_target == 0 )
				animate_target = animation_frames.size()-1; // last frame
			else
				animate_target = 0; // first frame
		}
		else
			super.command( cmd );
	}	
 	public void run()
 	{
 		while(1)
 		{
 			if(AnimateThread)
 			{
 				animate_time_delta = System.simTime()-animate_last_time;
 
 				the_car = null;
 				getCar_LocalVersion();
 
 				if( the_car && GameLogic.player && GameLogic.player && GameLogic.player.car && the_car == GameLogic.player.car.chassis ) // player is using this car
 				{
 					installed = 1;
					
					// animating section
					if( animate_target > animation_frames.size()-1 ) animate_target = animation_frames.size()-1;
					if( animate_target < 0.0 ) animate_target = 0.0;

					if( animate_progress != animate_target )
					{
						if( animate_progress < animate_target )
						{
							animate_progress += animate_time_delta * animate_speed;

							if( animate_progress >= animate_target )
								animate_progress = animate_target;
						}
						else
						{
							animate_progress -= animate_time_delta * animate_speed;

							if( animate_progress <= animate_target )
								animate_progress = animate_target;
						}
					}
					
					// control out of bounds
					if( animate_progress > animation_frames.size()-1 ) animate_progress = animation_frames.size()-1;
					if( animate_progress < 0.0 ) animate_progress = 0.0;
 
					// position needs update
 				if( animate_progress != animate_last_progress )
 				{
					if( animate_progress == (int)animate_progress ) // exactly frame match
					{
						Pori currFrame = new Pori( animation_frames.elementAt( (int)animate_progress ) );
							
						if( animate_slot_local )
							currFrame.mul( -1 );

							setSlotPos( animate_slot_nr, currFrame.pos.rotate( currFrame.ori ), currFrame.ori );
					}
					else // betwen two frames
						{

							Pori frameA = animation_frames.elementAt( (int)animate_progress );
							Pori frameB = animation_frames.elementAt( (int)(animate_progress+1) );

							Pori currFrame = new Pori();
							currFrame.diff( frameB, frameA ); // move betwen frames
							currFrame.mul( animate_progress - (int)animate_progress ); // current progress betwen frames

							currFrame.add( frameA );

							if( animate_slot_local )
								currFrame.mul( -1 );

							setSlotPos( animate_slot_nr, currFrame.pos.rotate( currFrame.ori ), currFrame.ori );
						}
						
					animate_last_progress = animate_progress;
 					}
					else
					if(AnimateThread) AnimateThread.sleep(50); // extra sleep
 
 					animate_last_time = System.simTime();
 					if(AnimateThread) AnimateThread.sleep(30); // Wait 0.03 sec (in theory will 33.3 FPS)
 		}
 			else
 			{
 				if( installed )
 				{
					Pori defaultFrame = new Pori( animation_frames.elementAt(0) );

					if( animate_slot_local )
						defaultFrame.mul( -1 );

 					setSlotPos( animate_slot_nr, defaultFrame.pos.rotate( defaultFrame.ori ), defaultFrame.ori );
 					animate_progress = 0;
 					installed = 0;
 				}
 
 				if(AnimateThread) AnimateThread.sleep( 2000 ); // Wait 2 sec
 			}
 		}
 	}
 }
}
I've tried to edit this script to trigger the animation when the player press the gas button, but i've failed (unfortunately i deleted my edited version due to rage xD).
public void command( String cmd ) //<the trigger
	{
		if( cmd == "flap_toggle" ) // cursor click
		{
			if( animate_target == 0 )
				animate_target = animation_frames.size()-1; // last frame
			else
				animate_target = 0; // first frame
		}
		else
			super.command( cmd );
	}
Take a look at the MFD (the "LCD" screen):
You can see that it shows up the turbo pressure and the oil pressure in a kinda simple way
If i remember well, in CorradoSKJ's Pagani Huayra theres some animated flaps that rotates when the player press the brake button, so i think that it can be easly edited to work with the gas pedal.
Also, i'm sorry for the late reply.