Question by
qiqette · Mar 08, 2016 at 02:37 PM ·
scripting problemraycastscripting beginnerdebugray
Why is not it casting any Ray? (THIS SHOULD BE EASY)
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour
{
public Transform childnofun;
void CastRaytoObject()
{
Debug.DrawRay(transform.position, childnofun.forward * 250, Color.red);
}
}
It isn't working neither:
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour
{
public Transform childnofun;
void CastRaytoObject()
{
Debug.DrawRay(transform.position, transform.position+ (childnofun.forward * 250), Color.red);
}
}
iwanttocry.png
(30.1 kB)
Comment
Answer by Jirogirg · Mar 08, 2016 at 02:54 PM
You are ehm.. calling that procedure from somewhere?
Of course, the big cube has the script, the little one is attached to the public transform
If that is the entire code, CastRaytoObject is never called, maybe you want to call it in Update() or Start()?
void Update(){
CastRaytoObject();
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612071043im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How can i place subjects in different positions? 0 Answers
Tetxure swap using HTC controllers 0 Answers
2D raycast not working 0 Answers
CAMERAS ERROR , I NEED HELP 0 Answers
Why can I only move upwards? 1 Answer