Question by
wyze-unity · Jul 27, 2016 at 01:04 PM ·
mouseclickmove an objectforces
impact mouseclick
using UnityEngine;
using System.Collections;
public class test : MonoBehaviour
{
// Update is called once per frame
void Update ()
{
if (Input.GetMouseButtonDown(0))
{
Debug.Log("click");
Ray r = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(r, out hit))
{
Debug.Log("Name Object : "+ hit.collider.name);
// Now How to apply a X1 force to the object in the point of impact on axis Z, and an X2 force to the object in the point of impact on axis Raycast to the object please ?
}
}
}
}
Comment
Your answer
Follow this Question
Related Questions
How do i move the game object towards the mouse clicked point smoothly? 0 Answers
OnMouseDown function not working on a gameObject 1 Answer
How do I make a rigid body move towards position of touch 0 Answers
OnMouseDown and OnMouseUp but not OnMouseUpAsButton? 1 Answer
Get click coordinates - Code was working before, but after copy/pasting now it isn't?, 0 Answers