can I invoke function faster than Update()?
Hi! I'm trying to create Lightsaber decal(you know, the MELTED effect). so far I made texture, applyed,etc. when I tested my decal drawing function, it shows not a line, but some dots. I believe this is because the function call is once per frame, which is Update() function. So can I invoke function "between" the frames? say, once per 0.0001 second? Sorry if this is already solved. I just cant find one. Thank you.
Answer by TheSorm · May 23, 2016 at 09:53 AM
You can use the Invoke command: http://docs.unity3d.com/ScriptReference/MonoBehaviour.InvokeRepeating.html
or you can use fixed update and go to gamesettings/Physiks/ and change the time there :)
I tried invokerepeating with 0.000015f as third argument in Start(), but it didn't worked. How weired, It should draw decal at every 0.000015f second, isn't it? But it too draws dot line... I'm stucked ;(
Cut you please show me youre code so i can see what you have done:)
#pragma strict
var maxDist : float = 2.23f;
var decalHit : GameObject;
var floatInFront : float = 0.0001;
function Start () {
InvokeRepeating("lp", 0, 0.000015f);
}
function lp() {
var hit : RaycastHit;
Debug.DrawRay(transform.position, transform.forward*2.23f);
if(Physics.Raycast(transform.position, transform.forward, hit, maxDist)){
Instantiate(decalHit, hit.point + (hit.normal * floatInFront), Quaternion.LookRotation(hit.normal));
}
Debug.DrawRay(hit.point, hit.normal);
}
}
this is it. It seems that if I can draw line between each hit.point rather than draw lots of decals it would much good. But I donno how ;(
Yes all right u used it like i say but in a simpler way, what i wrote was the basic stuff and u use the unity methode thats perfect :)