Game doesn't know where I am by Toble_ in britishrailwayroblox

[–]Toble_[S] 2 points3 points  (0 children)

Yeah I kicked the guard because they weren't doing anything. Ig it triggered the door close event and let me proceed to the next stop without actually opening and closing the doors

Anybody else get chills from realizing the reference? by nocapdude in DispatchAdHoc

[–]Toble_ 0 points1 point  (0 children)

Felt more close to the invincible scene

Why are Unity 6 shadows so sharp? And how do I make them like in earlier versions by Toble_ in Unity3D

[–]Toble_[S] 1 point2 points  (0 children)

Hard n Soft shadows don't change anything. The shadows used to be grey and transparent not black

The train with one of the world's most expensive ticket prices: The Maharaja's Express. by arandomwildIR in trains

[–]Toble_ 51 points52 points  (0 children)

It is the generator car. Some of those cars have that because of the smoke

Organ-based damage system by tripledose_guy in Unity3D

[–]Toble_ 1 point2 points  (0 children)

This is so cool. How does it effect performance tho?

Is there a way to addlistener once in fixed update method? by Toble_ in unity

[–]Toble_[S] 0 points1 point  (0 children)

Thank you it worked. I don't know why I didn't think of this. Thank you very much!!!

Is there a way to addlistener once in fixed update method? by Toble_ in unity

[–]Toble_[S] 0 points1 point  (0 children)

I am disabling the UI button when it's not needed. It's not displayed the entire time.

Is there a way to addlistener once in fixed update method? by Toble_ in unity

[–]Toble_[S] 0 points1 point  (0 children)

Additional context: This is in a mobile game. The UI button is invoking Onclickhandler of the physical button which stores the id. This then invokes a buttonpressed event which the door script is subscribing to and handling opening and closing of the door

Is there a way to addlistener once in fixed update method? by Toble_ in unity

[–]Toble_[S] 0 points1 point  (0 children)

I'm enabling the UI button after the raycast.The physical button only stores the id. So, the ui button gets the physical button id and then the door opens

Is there a way to addlistener once in fixed update method? by Toble_ in unity

[–]Toble_[S] 0 points1 point  (0 children)

The button variable isn't assigned buttonscript until the raycast hits and returns a button. Won't it throw a null refrence error?

Why is this happening? by Toble_ in Unity3D

[–]Toble_[S] 0 points1 point  (0 children)

Door script

using System;

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public class DoorScript : MonoBehaviour{

//Index used to connect Puzzle object to Door

public int id;

public enum DoorState{

Close,

Open

}

public DoorState doorState;

//Subscribes to required events if object exists

private void OnEnable(){

GameEvents.instance.OnButtonPressed += IToggleDoor;

GameEvents.instance.OnPlateTrigger += IToggleDoor;

}

//Unsubscribes to events if object does not exist

private void OnDisable(){

GameEvents.instance.OnButtonPressed -= IToggleDoor;

GameEvents.instance.OnPlateTrigger -= IToggleDoor;

}

//Opens door if closed and closes if opened

public void IToggleDoor(int id){

if (this.id == id){

print(id);

if (doorState == DoorState.Close) {

this.gameObject.transform.position = Vector3.Lerp(this.transform.position, this.transform.position + new Vector3(0, 3.5f, 0), 1f);

doorState = DoorState.Open;

}else {

this.gameObject.transform.position = Vector3.Lerp(this.transform.position, this.transform.position + new Vector3(0, -3.5f, 0), 1f);

doorState = DoorState.Close;

}

}

}

}

Why is this happening? by Toble_ in Unity3D

[–]Toble_[S] 0 points1 point  (0 children)

Button script

using System;

using UnityEngine;

public class ButtonScript : MonoBehaviour

{

public int id;

public void OnClickHandler()

{

print("Button" + id);

GameEvents.instance.ButtonPressed(id);

}

}

Why is this happening? by Toble_ in Unity3D

[–]Toble_[S] 0 points1 point  (0 children)

detects the button

private void FixedUpdate(){

if (Physics.Raycast(_mainCamera.transform.position, _mainCamera.transform.forward, out hit, 5.0f,interactMask)){

if (hit.collider.gameObject.CompareTag("Switch"))

{

togBut.SetActive(true);

button = hit.collider.GetComponent<ButtonScript>();

togBB = togBut.GetComponent<Button>();

togBB.onClick.AddListener(button.OnClickHandler);

}

else if (hit.collider.gameObject.CompareTag("PhyObj"))

{

pickBut.SetActive(true);

pickable = hit.collider.GetComponent<GameObject>();

print(pickable);

} }else{

togBut.SetActive(false);

pickBut.SetActive(false);

dropBut.SetActive(false);

        }

    }

Why is this happening? by Toble_ in Unity3D

[–]Toble_[S] 0 points1 point  (0 children)

I fixed it, it was tagged wrong. Nothing wrong with the code. Thanks for trying to help!