Не прямая стрельба 
				  
gggaptypggg Дата: Вторник, 08 Января 2013, 20:39 | Сообщение # 1   
 
почетный гость
Сейчас нет на сайте 
 
 Всем привет. Нашел скрипт стрельбы в интернете, прикрепил объект рук и пистолета, поставил прицел, а тут.      В чем может быть проблема?   Вот скрипт стрельбы.   
var cameraObject : GameObject;   @HideInInspector   var targetXRotation : float;   @HideInInspector   var targetYRotation : float;   @HideInInspector   var targetXRotationV : float;   @HideInInspector   var targetYRotationV : float;   var rotateSpeed : float = 0.3;   var holdHeight : float = -0.5;   @HideInInspector   var Shot : boolean;   var GunAutomatical : boolean;   var holdSide : float = 0.5;   var racioHipHold : float = 1;   var hipToAimSpeed : float = 0.1;   @HideInInspector   var racioHipHoldV : float;   var aimRacio : float = 0.4;   var zoomAngle : float = 30;   var fireSpeed : float = 15;   @HideInInspector   var waitTilNextFire : float = 0;   var bullet : GameObject;   var bulletSpawn : GameObject;   var shootAngleRandomizationAiming : float = 5;   var shootAngleRandomizationNotAiming : float = 15;   var recoilAmount : float = 0.5;   var recoilRecoverTime : float = 0.2;   @HideInInspector   var currentRecoilZPos : float;   @HideInInspector   var currentRecoilZPosV : float;   var bulletSound : GameObject;   var muzzelFlash : GameObject;   function Update ()   {   	var holdMuzzelFlash : GameObject;   	var holdSound : GameObject;   	if (Input.GetButton("Fire1") && Shot == false)   	{   		if (waitTilNextFire <= 0)   		{   			if (bullet)   				Instantiate(bullet,bulletSpawn.transform.position, bulletSpawn.transform.rotation);   			if (bulletSound)   				holdSound = Instantiate(bulletSound, bulletSpawn.transform.position, bulletSpawn.transform.rotation);   			if (muzzelFlash)   				holdMuzzelFlash = Instantiate(muzzelFlash, bulletSpawn.transform.position, bulletSpawn.transform.rotation);   			targetXRotation += (Random.value - 0.5) * Mathf.Lerp(shootAngleRandomizationAiming, shootAngleRandomizationNotAiming, racioHipHold);   			targetYRotation += (Random.value - 0.5) * Mathf.Lerp(shootAngleRandomizationAiming, shootAngleRandomizationNotAiming, racioHipHold);   			currentRecoilZPos -= recoilAmount;   			waitTilNextFire = 1;   			if(GunAutomatical == false)   			{   				Shot = true;   			}   		}   	}   	if (Input.GetButton("Fire1") == false && Shot == true){Shot = false;}   	waitTilNextFire -= Time.deltaTime * fireSpeed;   	if (holdSound)   		holdSound.transform.parent = transform;   	if (holdMuzzelFlash)   		holdMuzzelFlash.transform.parent = transform;   	currentRecoilZPos = Mathf.SmoothDamp( currentRecoilZPos, 0, currentRecoilZPosV, recoilRecoverTime);   	cameraObject.GetComponent(MouseLookScript).currentTargetCameraAngle = zoomAngle;   	if (Input.GetButton("Fire2")){   		cameraObject.GetComponent(MouseLookScript).currentAimRacio = aimRacio;   		racioHipHold = Mathf.SmoothDamp(racioHipHold, 0, racioHipHoldV, hipToAimSpeed);}   	if (Input.GetButton("Fire2") == false){   		cameraObject.GetComponent(MouseLookScript).currentAimRacio = 1;   		racioHipHold = Mathf.SmoothDamp(racioHipHold, 1, racioHipHoldV, hipToAimSpeed);}   	transform.position = cameraObject.transform.position + (Quaternion.Euler(0,targetYRotation,0) * Vector3(holdSide * racioHipHold, holdHeight * racioHipHold, 0) + Quaternion.Euler(targetXRotation, targetYRotation, 0) * Vector3(0,0,currentRecoilZPos));   	   	targetXRotation = Mathf.SmoothDamp( targetXRotation, cameraObject.GetComponent(MouseLookScript).xRotation, targetXRotationV, rotateSpeed);   	targetYRotation = Mathf.SmoothDamp( targetYRotation, cameraObject.GetComponent(MouseLookScript).yRotation, targetYRotationV, rotateSpeed);   	   	transform.rotation = Quaternion.Euler(targetXRotation, targetYRotation, 0);   }
 
 
 
 
 
Anim Дата: Вторник, 08 Января 2013, 21:27 | Сообщение # 2   
 
постоянный участник
Сейчас нет на сайте 
 
 а в чём проблема то? =))) 
всем бобра! 
 
 
 
gggaptypggg Дата: Вторник, 08 Января 2013, 21:50 | Сообщение # 3   
 
почетный гость
Сейчас нет на сайте 
 
 Anim , Криво стреляет 
 
 
 
 
Jlovenpk1 Дата: Вторник, 08 Января 2013, 22:05 | Сообщение # 5   
 
участник
Сейчас нет на сайте 
 
 у тебя дуло в одно место, прицел в другое.   Вроде в Random.Value ошибка 
DjanStudio  
Сообщение отредактировал Jlovenpk1  - Вторник, 08 Января 2013, 22:05 
 
 
 
gggaptypggg Дата: Вторник, 08 Января 2013, 22:43 | Сообщение # 6   
 
почетный гость
Сейчас нет на сайте 
 
 Завтра отпишусьДобавлено  (08.01.2013, 22:43) ---------------------------------------------Jlovenpk1 , Неа, не работает. Я ее убрал и тоже самое.
 
 
Сообщение отредактировал gggaptypggg  - Вторник, 08 Января 2013, 22:14 
 
 
 
seaman Дата: Вторник, 08 Января 2013, 23:08 | Сообщение # 7   
старожил
Сейчас нет на сайте 
 
 может bulletSpawn слегка повернут относительно прицела? Потому пуля летит слегка не туда. 
 
 
 
gggaptypggg Дата: Вторник, 08 Января 2013, 23:10 | Сообщение # 8   
 
почетный гость
Сейчас нет на сайте 
 
 seaman , Bulletspawn отвечает только за место где создается. 
 
 
 
 
seaman Дата: Вторник, 08 Января 2013, 23:19 | Сообщение # 9   
старожил
Сейчас нет на сайте 
 
 И за направление в котором смотрит. Как пуля движется? Наверняка просто по прямой. Куда смотрела - туда и полетит/ 
 
 
 
gggaptypggg Дата: Среда, 09 Января 2013, 12:09 | Сообщение # 10   
 
почетный гость
Сейчас нет на сайте 
 
 Спасибо, разобрался. Проблема была в Bulletspawn. seaman , ты был прав.