Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System.Linq.Expressions;
- public class sultan : MonoBehaviour
- {
- private GameObject sultanPref;
- // Use this for initialization
- void Start () {
- sultanPref=Resources.Load("sultan") as GameObject;;
- }
- // Update is called once per frame
- void Update () {
- if (Input.GetKeyDown(KeyCode.Space))
- {
- RaycastHit hit = new RaycastHit();
- Ray ray = new Ray(transform.position, transform.forward);
- if (Physics.Raycast(ray, out hit, 100))
- {
- GameObject go = (GameObject) Instantiate(sultanPref, hit.point, Quaternion.LookRotation(transform.forward));
- go.transform.GetComponent<Renderer>().material = hit.collider.transform.GetComponent<Renderer>().material;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement