Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I would like help with a simple script for Unity 3d. I want to be able to have a trigger collision with a GameObject Circle.

I would like help with a simple script for Unity 3d. I want to be able to have a trigger collision with a GameObject Circle. When my player moves over the Circle an object with a light attached to it will rise up from the center of the circle. The light will turn on. I would like it to rise slowly. It can only be activated once. I have the general code working from a different script, I just can't seem to get it to go up, it goes horizontally.

onTriggerEnter(Collider other){

if (start position == false){ ObjectCloseTarget = object.localPosition;

ObjectOpenTarget = new Vector3( object.localPosition.x, object.localPosition.y + (sizeOfObjectInY * amountOfObjectInFloor), object.localPosition.z);

totalDistanceToCover = Vector3.Distance(ObjectCloseTarget, ObjectOpenTarget);

LiftObject();

float distanceCovered = (Time.time - startTime) * moveSpeed; float fractionDist = distanceCovered / totalDistanceToCover;

object.localPosition = Vector3.Lerp(object.localPosition, ObjectOpenTarget, fractionDist);

if (Mathf.Approximately(object.localPosition.y, objectOpenTarget.y)){

startPosition = true; //it has been activated switchLight.SetActive(true); }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Online Market Research Cost Effective Searching Of The Internet And Online Databases

Authors: John F. Lescher

1st Edition

0201489295, 978-0201489293

More Books

Students also viewed these Databases questions

Question

What is a trust fund?

Answered: 1 week ago

Question

c. What groups were least represented? Why do you think this is so?

Answered: 1 week ago

Question

7. Describe phases of multicultural identity development.

Answered: 1 week ago