So far I have this script:
using System.Collections.Generic;
using UnityEngine;
using System.Collections;
public class placer : MonoBehaviour
{
Ray SRay;
Ray myRay;
RaycastHit myHit;
RaycastHit SHit;
public GameObject WhatObject;
private void Update()
{
var myRay = Camera.main.ScreenPointToRay(Input.mousePosition);
if(Physics.Raycast(myRay, out myHit))
{
if (Input.GetMouseButtonDown(0))
{
Instantiate(WhatObject, myHit.point, Quaternion.identity);
}
}
var SRay = Camera.main.ScreenPointToRay(Input.mousePosition);
if(Physics.Raycast(SRay, out SHit))
{
[B]///HELP [/B]
}
}
}
I want to assign an object hit by SHit (selection hit), to the GameObject ‘WhatObject’, using RightMouseButton, so I can place it using LeftMouseButton.
can somebody help me out please?