Search the Community
Showing results for tags 'turret'.
-
Hi. I would like to make the rotation of the gun at -45 and +45 (or less) degrees relative to that of the camera. When I limit the values, it only works according to the world coordinate. For example, when I turn a full turn to the left, I have to turn a full turn right again so that the gun rotates in the right direction. I want to do a gun control like Insurgency game. How can I fix this? Here is my code. float currentTime = Time::GetCurrent(); Vec2 currentMousePos = Window::GetCurrent()->GetMousePosition(); Window::GetCurrent()->SetMousePosition(Math::Round(Context::GetCurrent()->GetWidth() / 2), Math::Round(Context::GetCurrent()->GetHeight() / 2)); Vec2 centerPos = Window::GetCurrent()->GetMousePosition(); currentMousePos.x = Math::Round(currentMousePos.x); currentMousePos.y = Math::Round(currentMousePos.y); mouseDifference.x = Math::Curve(currentMousePos.x - centerPos.x, mouseDifference.x, 2 / Time::GetSpeed()); mouseDifference.y = Math::Curve(currentMousePos.y - centerPos.y, mouseDifference.y, 2 / Time::GetSpeed()); camRotation.x = Math::Clamp(camRotation.x + mouseDifference.y / mouseSensitivity, -90, 90); camRotation.y = camRotation.y + (mouseDifference.x / mouseSensitivity); hurtOffset.x = Math::Inc(0, hurtOffset.x, 2 * Time::GetSpeed()); hurtOffset.y = Math::Inc(0, hurtOffset.y, 2 * Time::GetSpeed()); smoothedHurtOffset.x = Math::Curve(hurtOffset.x, smoothedHurtOffset.x, 3); smoothedHurtOffset.y = Math::Curve(hurtOffset.y, smoothedHurtOffset.y, 3); bobOffset.x = Math::Inc(0, bobOffset.x, Time::GetSpeed() * 0.8f); bobOffset.y = Math::Inc(0, bobOffset.y, Time::GetSpeed()); smoothedBobOffset.x = Math::Curve(bobOffset.x, smoothedBobOffset.x, 25); smoothedBobOffset.y = Math::Curve(bobOffset.y, smoothedBobOffset.y, 25); weaponViewRot.x = Math::Clamp(camRotation.x + mouseDifference.y / mouseSensitivity, -45, 45); weaponViewRot.y = Math::Clamp(camRotation.y + mouseDifference.x / mouseSensitivity, -45, 45); smoothWeaponViewRot.x = Math::Curve(weaponViewRot.x, smoothedHurtOffset.x, 5); smoothWeaponViewRot.y = Math::Curve(weaponViewRot.y, smoothedHurtOffset.x, 5); playerCamera->SetRotation(camRotation + smoothedBobOffset + smoothedHurtOffset); testWeapon->entity->SetRotation(camRotation + smoothWeaponViewRot); if (Window::GetCurrent()->MouseDown(1)) { testWeapon->weaponShoot(); }
-
http://pastebin.com/yQ2jHPii > I put my script on pastebin for better overview. This is the script I attached to a turret . Basic explaination: It ckecks for enemies nearby and alligns itself to them, calls shoot() function once in a while. The Bullet itself is only for the visual. To hurt the enemy, I will later acces the enemy script trough the turret and call a hurt function. In the start funcion I set up an emitter which should look like a bullet flying . I want to know how i properly let the emitter play , and have multiple bullets at one time. ( or just how to play it , i can make the bullet run faster so it would be no problem if it gets resetted). I made an attempt in the Shoot() function, but i cant see anything inside the game. 2 The performance is still a littlebit low, I can spawn ~30 turrets at normal fps and when I spawn more it gets lower (not over time, the more turrets the less fps). I personally think its caused by my computer or lua, but still if you can find anything that could cause less performance please tell.
-
I am currently getting problems with the Fpsgun script. I made a prefab and attached it to an turret in the map via path. http://pastebin.com/LapGp5nw Heres the modified fpsgun script. In detail the problem is that the muzzle (shooting direction) should always be in front direction of the turret. The second problem is that the script doesnt know the fpsplayer anymore, so there is no camera to align the effects to. There are going to be multiple turrets in the game, so there should be a global camera, but I dont know how to set it up . I have tried to fix it but it doesnt work really well. I would apprechiate any help on this.
-
Above some screenshots that are important to understand the problem. function Script:UpdatePhysics() self.entity:Point(self.target, 1, Time:GetSpeed() * self.rotSpeed) end This is a part of my code. The first screenshot is what happens when i run the game. The crawler runs around a path, the turret points at him but is rotated in negative y. What can I do to prevent this ?