

You can see in the screenshot that the bone's default X rotation is roughly -50.Įnemies walk through the trench around the turret. Here's a picture of the turret to give you an idea what I'm working with. GunBox.RotateAround(gunBox.position, Vector3.left, angle) Vector3 gunBoxPosition = gunBox.position įloat angle = Vector3.Angle(gunBoxPosition, targetPosition) Transform gunBox = ("Armature/BaseBone/PlatformBone/LowerArmBone/UpperArmBone/GunBoxBone") Rotate GunBox //#TO DO: This part is not working = Quaternion.Lerp(, targetRotation, rotateSpeed) TargetRotation = Quaternion.LookRotation(targetPosition - turretPosition) įloat rotateSpeed = 2.0f * ltaTime Vector3 targetPosition = enemyManager.activeEnemies].transform.position TurretPosition.y = 0 //0 the Y axis to stop the turret tilting up or down Vector3 turretPosition = platform.position //Store the turrets current position Quaternion targetRotation //Final rotation (I.e. Transform platform = ("Armature/BaseBone/PlatformBone") Rotate Platform //# This section works fine
#Spine2d flip unity3d code#
Here is the code I have at the moment: if (enemiesInRange.Count > 0) Basically everything except where it's supposed to be looking. So far I've managed to get it to look down at its base, up at the sky and spin like a wheel.

I have tried various things, including examples from the Internet but I can't figure it out. I need it to keep facing the same direction as the rest of the turret and don't want it to tilt to either side. The second which I can't get right needs to rotate the gun at the top of the turret to look down at the enemy.

The first bone (which I have working) rotates the turret to face the direction of the enemy. I've created a basic turret in Blender and I'm now trying to rotate 2 different bones to make the turret follow the enemy. Transform.localScale = new Vector3( /, /, / 'm new to game development and I'm trying to create a basic 3D Tower Defence game as my first project. Transform.rotation = Īnd the Scaling Script: public class Scaler : MonoBehaviour Transform.position = Įlse if (distCheck ().useGravity = false If (distCheck >= unsnapMouseDist & isClicked) Empty Object (scale (0.5,0.5,0.5)) this is the parent set to the same scale as the snappable object public class Interactable : MonoBehaviourĭistCheck = Vector3.Distance(pickUpDestination.position, snapPointPos) Ship (scale (2,2,2)) parent of the parent Please ignore other issues that may be in the code at this point unless they directly are affecting the scaling issue. Maybe someone can see something I am missing. I have tried hierarchal fixes using empty game objects and nothing seems to be maintaining a constant global scale for my child objects.

I've tried stepping through the logical way one would go about doing this. I have tried attaching scaling scripts that dynamically scale the child object based on the parent object scale. The script works as intended but the child objects continue to be scaled with the parent object. I have been attempting to snap game objects to other game objects at runtime (such as to equip ship parts to a ship). I have read so many forum posts but none are working for me. Fairly new to Unity and have tried several solutions without success.
