protected void PrepareDecalForSpawning(DecalSpawner spawner, Vector3 spawnPosition) { float rotation = Random.Range(0, 360); Vector2 scaledSize = brush.size * Random.Range(0.7f, 1.3f); spawner.Spawn(spawnPosition, scaledSize, rotation, material, brush.decal); }
// Update is called once per frame override public void Fire() //mousedown { if (line == null) { createLine(); currVertex = 1; } Ray ray = new Ray(shotSpawnPoint.position, shotSpawnPoint.forward); RaycastHit hit = new RaycastHit(); if (Physics.Raycast(ray, out hit)) //, LayerMask.NameToLayer("DecalPlane"))) { Debug.Log(hit.transform.gameObject.name); hitPos = hit.point; //hitPos = hit.transform.InverseTransformPoint(hit.point); //hitPos = hit.transform.TransformPoint(hit.point); DecalSpawner decalSpawner = hit.collider.gameObject.GetComponent<DecalSpawner>(); if (decalSpawner) decalSpawner.Spawn(material, line); timeOfLastVertex = Time.time; line.SetPosition(0, hitPos); line.SetPosition(currVertex, hitPos); } }