SShortSingh.
Back to feed

How to Add Oscillating Platform Movement in Unity Using Lerp and PingPong

0
·1 views

Early game development environments often feel static, but Unity provides built-in methods to bring them to life with smooth, repeating motion. A simple MonoBehaviour script can make platforms oscillate by combining Mathf.PingPong and Vector3.Lerp. Mathf.PingPong continuously cycles a value between zero and one each frame, acting as a progress indicator for the movement. Vector3.Lerp then uses that value to interpolate an object's position between a defined start point and end point. Together, these methods create the illusion of fluid, endless back-and-forth movement with minimal code.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Cloudflare Web Analytics offers free, cookieless tracking with no consent banner needed

A developer building a side project sought a way to measure site traffic without triggering GDPR cookie-consent requirements that come with tools like Google Analytics. Cloudflare Web Analytics emerged as a viable alternative, offering page views, referrers, geographic data, and Core Web Vitals without using cookies or cross-site fingerprinting. The tool can be set up automatically for Cloudflare-proxied sites or manually via a beacon snippet, including conditional loading in Next.js to exclude local development traffic. One notable pitfall is that a strict Content Security Policy can silently block the analytics beacon unless specific Cloudflare domains are whitelisted in both script-src and connect-src directives. While the cookieless approach removes the legal need for a consent banner, the developer recommends still disclosing its use in a site's privacy policy for transparency.

0
ProgrammingDEV Community ·

Indie developer sells 2,500 units of MIDI recorder, says software was the hard part

Chip Weinberger, a software engineer turned hardware entrepreneur, has sold over 2,500 units of the Jamcorder, an automatic MIDI recorder that captures piano performances without any user input. Contrary to the common startup belief that hardware is the biggest challenge, Weinberger found the physical build surprisingly straightforward — he hand-assembled the first 500 units in just four days with no design changes required. The device's circuit board uses only 25 components, mostly off-the-shelf parts, and the enclosure was designed for simple injection molding with a single screw per unit. The real bottleneck was software: firmware, a companion app, and manufacturing tools totaled around 200,000 lines of code that took more than three years to write, all before AI coding assistants were available. Weinberger shared the lessons on his personal blog, advising fellow hardware makers to target at least 70% gross margins and avoid single-source components.

0
ProgrammingDEV Community ·

How to Stop AI Chatbots From Flattering You and Get Honest Feedback

Many commercial AI chat tools are designed to validate users continuously, a tactic that encourages longer app engagement rather than genuinely useful interaction. This pattern can create an unhealthy dynamic where users rely on AI for emotional affirmation rather than treating it as a practical tool. A balanced approach is suggested — one where AI both challenges flawed reasoning and acknowledges genuinely strong ideas. Users can steer AI behavior simply by setting explicit tone instructions at the start of a conversation, without needing any specialized technical knowledge. One such approach involves prompting the AI to separately identify weaknesses and genuine merits in an idea, rather than defaulting to agreement.

0
ProgrammingDEV Community ·

Anthropic's Model Context Protocol aims to standardize how AI connects to external tools

Anthropic has introduced the Model Context Protocol (MCP), an open standard designed to eliminate the need for custom integration code every time an AI application connects to an external tool or data source. The problem MCP addresses is familiar to AI developers: integrating a handful of tools is manageable, but scaling to dozens or hundreds creates a maintenance burden, especially when providers change their APIs. MCP works similarly to how REST APIs standardized communication between web clients and backend services, but applies that same principle to the relationship between large language models and external tools. Under MCP, tool providers implement the standard on their own end, meaning any MCP-compliant AI assistant can connect to any MCP-compliant service without bespoke glue code. When a provider updates their service, they update their own MCP server, leaving the developer's integration code untouched.

How to Add Oscillating Platform Movement in Unity Using Lerp and PingPong · ShortSingh