Question by
AnotherGuy_Evan · Feb 12, 2017 at 05:45 PM ·
raycasttransform.positionraycasthitgameobject.name
Apply Transform to gameObject hit by Raycast
So quite simply I want to be able to pickup/translate an object in y IF it has a certain tag AND a key is pressed, but I'm not sure how to call on that gameObject that is hit.
I've commented a bit of my thought process, I just don't know if I can store the details of the gameObject that is hit, then apply my transform to that stored gameObject, or if I have to apply the transform live to the hit.transform.gameObject.name
// determines whether or not object can be abducted.
if (hit.transform.tag == "abductable" && (Input.GetKey(KeyCode.Space)))
{
Debug.Log(hit.collider.gameObject.name + " abductable.");
//Want to store hit gameObject, and apply a transform relative to time to it while the key is being held.
//Code below is me thinking out loud
//float abductRate = 10;
//transform.Translate = (time.DeltaTime * abductRate)
//gameObject.transform.position +- Vector3.up * 1;
}
Comment
Your answer
Follow this Question
Related Questions
RayCastHit 2d with layerMask not workin 0 Answers
Help with Raycast Script 0 Answers
Transform.up doesnt give me it´s local up position 1 Answer
A cube, raycasthit and rotation 0 Answers
Raycast Going Though walls 0 Answers