Question
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
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