Username Username - 1 year ago 98
C# Question

Debug log is not working for FixedUpdate

Debug.log works fine in

function but not in
. Not sure what is wrong

using UnityEngine;
using System.Collections;

public class PickupParent : MonoBehaviour {

SteamVR_TrackedObject trackedObj;

void Awake () {
trackedObj = GetComponent<SteamVR_TrackedObject>();
Debug.Log("debug log is working");

// Update is called once per frame
void FixedUpdated () {
SteamVR_Controller.Device device = SteamVR_Controller.Input((int)trackedObj.index);

if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
Debug.Log("You are holding down the 'Touch' on the Trigger");

Answer Source

Looks like you added an extra d to the function name FixedUpdated should be FixedUpdate.

// Update is called once per frame
void FixedUpdated () { // <---------- should be FixedUpdate

Also the first thing I would have tried is added a Debug.Log call at the start of FixedUpdate to see if the function was being called at all. It not being called would have indicated an issue with the function. If it was called then it would have pointed to the if statement wrapped around the log call.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download