// ============================================= // #endregion // Start is called before the first frame update void Start() { // Extract terrain information if (!terrain) { //terrain = Terrain.activeTerrain; terrain = myBipedalCharacter.GetComponent <RigidBodyControllerSimpleAnimator>().currentTerrain; Debug.Log("[INFO] Main terrain: " + terrain.name); } terrain_collider = terrain.GetComponent <Collider>(); terrain_data = terrain.terrainData; terrain_size = terrain_data.size; heightmap_width = terrain_data.heightmapResolution; heightmap_height = terrain_data.heightmapResolution; heightmap_data = terrain_data.GetHeights(0, 0, heightmap_width, heightmap_height); heightmap_data_constant = terrain_data.GetHeights(0, 0, heightmap_width, heightmap_height); heightmap_data_filtered = terrain_data.GetHeights(0, 0, heightmap_width, heightmap_height); brushPhysicalFootprint = null; // Get classes _feetPlacement = FindObjectOfType <IKFeetPlacement>(); // Retrieve components and attributes from character mass = myBipedalCharacter.GetComponent <Rigidbody>().mass; _anim = myBipedalCharacter.GetComponent <Animator>(); // Time elapsed -> TODO: Smoothing //elapsed = 0f; // Old Feet Y-component position oldIKLeftPosition = _anim.GetBoneTransform(HumanBodyBones.LeftFoot).position; oldIKRightPosition = _anim.GetBoneTransform(HumanBodyBones.RightFoot).position; oldIsMoving = _anim.GetBool("isWalking"); }
// Start is called before the first frame update void Start() { // Extract terrain information if (!terrain) { terrain = Terrain.activeTerrain; } terrain_collider = terrain.GetComponent <Collider>(); terrain_data = terrain.terrainData; terrain_size = terrain_data.size; heightmap_width = terrain_data.heightmapResolution; heightmap_height = terrain_data.heightmapResolution; heightmap_data = terrain_data.GetHeights(0, 0, heightmap_width, heightmap_height); heightmap_data_constant = terrain_data.GetHeights(0, 0, heightmap_width, heightmap_height); heightmap_data_filtered = terrain_data.GetHeights(0, 0, heightmap_width, heightmap_height); brushPhysicalFootprint = null; // Get classes _feetPlacement = FindObjectOfType <IKFeetPlacement>(); _ragdoll = FindObjectOfType <Ragdoll>(); // Retrieve mass from Ragdoll mass = _ragdoll.CalculateMass(); // Time elapsed elapsed = 0f; // Old Feet Y Position oldIKLeftPosition = _anim.GetBoneTransform(HumanBodyBones.LeftFoot).position; oldIKRightPosition = _anim.GetBoneTransform(HumanBodyBones.RightFoot).position; oldIsMoving = _anim.GetBool("isWalking"); }
public void Activate() { BrushPhysicalFootprint active_brush = terrain.GetFootprintBrush(); if (active_brush) { active_brush.Deactivate(); } terrain.SetFootprintBrush(this); active = true; }
public override void OnInspectorGUI() { BrushPhysicalFootprint myBrush = (BrushPhysicalFootprint)target; if (myBrush.IsActive()) { DrawDefaultInspector(); } if (ToggleButtonStyleNormal == null) { ToggleButtonStyleNormal = "Button"; ToggleButtonStyleToggled = new GUIStyle(ToggleButtonStyleNormal); ToggleButtonStyleToggled.normal.background = ToggleButtonStyleToggled.active.background; } GUIStyle style = myBrush.IsActive() ? ToggleButtonStyleToggled : ToggleButtonStyleNormal; if (GUILayout.Button("Use", style)) { myBrush.Toggle(); } }
// Get and set active brushes public void SetFootprintBrush(BrushPhysicalFootprint brush) { Debug.Log("[INFO] Setting brush to " + brush); brushPhysicalFootprint = brush; }