Answered step by step
Verified Expert Solution
Question
1 Approved Answer
How can in modify my Vertical moving Platform code ( Unity , C# ) to creat a script thats makes platforms move in a circular
How can in modify my Vertical moving Platform code Unity C# to creat a script thats makes platforms move in a circular motion? using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class VMovingPlatforms : MonoBehaviour
SerializeField private Transform topedge;
SerializeField private Transform bottomedge;
HeaderPlatform
SerializeField private Transform platform;
HeaderMovement Parameters"
SerializeField private float speed;
private Vector initScale;
private bool movingUp;
HeaderIdle Time"
SerializeField private float idleDuration;
private float idleTimer;
private void Awake
initScale platform.localScale;
Adapt for vertical moving platform
void Update
if movingUpif platform moving up
if platform posotion y is greater than or equak to bottomedge position y
if platformposition.y bottomedge.position.y
call MoveInDirection function and pass as argument
MoveInDirection;
else
calls change direction
DirectionChange;
else
if platform pos Y is less than or equal to the top edge Y positio
if platformposition.y topedge.position.y
calls MoveInDirection functioin and passes as an argument
MoveInDirection;
else
change direction
DirectionChange;
private void MoveInDirectionint direction
set idleTimer to
idleTimer ;
makes platform move
platform.position new Vectorplatformposition.x platform.position.y Time.deltaTime direction speed, platform.position.z;
Change Direction Functiom
private void DirectionChangechange direction of platform
idleTimer Time.deltaTime;
if idleTimer is greater than idleDuration
if idleTimer idleDuration
reverse direction
movingUp movingUp;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started