ESP32 Ventilation Diagnostic Module Design
1:27
Clarifying scripting response.
Navigating tool usage for Unity.
Considering jump mechanics.
Building a PlayerController2D script.
Creating a PlayerController2D script.
Csharp
using UnityEngine; public class PlayerController2D : MonoBehaviour { [Header("Movement")] public float moveSpeed = 8f; [Header("Jumping")] public float jumpForce = 14f; public int extraJumps = 1; // double-jump => 1 public float coyoteTime = 0.10f; // grace after leaving ground public float jumpBuffer = 0.10f; // buffer before landing [Header("Walls")] public float wallSlideSpeed = 2f; public Vector2 wallJumpForce = new Vector2(12f, 14f); public float wallJumpControlLock = 0.18f; // brief horizontal lock after wall-jump [Header("Checks")] public Transform groundCheck; public Transform wallCheckLeft; public Transform wallCheckRight; public float checkRadius = 0.18f; public LayerMask groundLayer; Rigidbody2D rb; int jumpsLeft; float coyoteCounter; float jumpBufferCounter; float lastWallJumpTime; bool grounded, onWallLeft, onWallRight; float inputX; bool facingRight = true; void Awake() { rb = GetComponent(); jumpsLeft = extraJumps; } void Update() { // Input inputX = Input.GetAxisRaw("Horizontal"); if (Input.GetButtonDown("Jump")) jumpBufferCounter = jumpBuffer; else jumpBufferCounter -= Time.deltaTime; // Checks grounded = Physics2D.OverlapCircle(groundCheck.position, checkRadius, groundLayer); onWallLeft = Physics2D.OverlapCircle(wallCheckLeft.position, checkRadius, groundLayer); onWallRight = Physics2D.OverlapCircle(wallCheckRight.position, checkRadius, groundLayer); bool onWall = (onWallLeft || onWallRight) && !grounded; int wallDirX = onWallLeft ? -1 : (onWallRight ? 1 : 0); // Coyote + jump reset if (grounded) { coyoteCounter = coyoteTime; jumpsLeft = extraJumps; } else coyoteCounter -= Time.deltaTime; // Wall slide if (onWall && rb.velocity.y < 0 && Mathf.Sign(inputX) == wallDirX) { rb.velocity = new Vector2(rb.velocity.x, Mathf.Max(rb.velocity.y, -wallSlideSpeed)); } // Jump logic (buffered) if (jumpBufferCounter > 0f) { if (grounded || coyoteCounter > 0f) { Jump(Vector2.up * jumpForce); } else if (onWall) { // Push off opposite to wall Vector2 v = new Vector2(-wallDirX * wallJumpForce.x, wallJumpForce.y); Jump(v); lastWallJumpTime = Time.time; } else if (jumpsLeft > 0) { Jump(Vector2.up * jumpForce); jumpsLeft--; } } // Horizontal move (briefly limited after wall-jump) bool lockControl = Time.time < lastWallJumpTime + wallJumpControlLock; float h = lockControl ? 0f : inputX; rb.velocity = new Vector2(h * moveSpeed, rb.velocity.y); // Face direction if (h != 0) { if ((h > 0 && !facingRight) || (h < 0 && facingRight)) Flip(); } } void Jump(Vector2 impulse) { // consume buffer now jumpBufferCounter = 0f; // keep existing x, replace y (for consistent height) rb.velocity = new Vector2(rb.velocity.x, 0f); rb.velocity += impulse; } void Flip() { facingRight = !facingRight; var s = transform.localScale; s.x = Mathf.Abs(s.x) * (facingRight ? 1f : -1f); transform.localScale = s; } void OnDrawGizmosSelected() { if (groundCheck) { Gizmos.color = Color.green; Gizmos.DrawWireSphere(groundCheck.position, checkRadius); } if (wallCheckLeft) { Gizmos.color = Color.cyan; Gizmos.DrawWireSphere(wallCheckLeft.position, checkRadius); } if (wallCheckRight) { Gizmos.color = Color.cyan; Gizmos.DrawWireSphere(wallCheckRight.position, checkRadius); } } }
Input.GetKeyDown(KeyCode.Space) if preferred.extraJumps for triple jumps.wallJumpControlLock for more/less “push-off” feel.coyoteTime and jumpBuffer for forgiveness.Ready.
\#portal) will be used to connect different parts of the schematic, but no connections have been made yet.STM32F4: SPI MOSI à 74HC595: SER (Donnée série)STM32F4: SPI SCK à 74HC595: SRCLK (Horloge de décalage)STM32F4: GPIO (dédié) à 74HC595: RCLK (Horloge de registre)74HC595: Q7' (sortie de décalage) se connecte à 74HC595 suivant: SER.C
void sendToShiftRegister(uint8_t *data, size_t len) { HAL_SPI_Transmit(&hspi1, data, len, HAL_MAX_DELAY); // Pulse the RCLK to latch the data to the output HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_SET); HAL_Delay(1); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_RESET); HAL_Delay(1); }
Reviews
Inspect
Net Portal
Controls
Properties
Availability & Pricing
| Distributor | Qty 1 | |
|---|---|---|
Assets
Welcome 👋
Flux accelerates your PCB design with AI.
Create your account to start using this component and bring your ideas to life.
david998
copilot