Search Unity

Problem with raycast and javascript

Discussion in 'Scripting' started by Mirace, Apr 7, 2011.

  1. Mirace

    Mirace

    Joined:
    Nov 29, 2010
    Posts:
    481
    Im getting error
    Code (csharp):
    1. BCE0034: Expressions in statements must only be executed for their side-effects.
    And i dont see anything what causes it. error highlights line "hitInfo.collider.transform.position.forward * Time.deltaTime;"
    here is the code:
    Code (csharp):
    1.  
    2. if( Physics.Raycast( Camera.allCameras[0].ScreenPointToRay( Input.mousePosition ), hitInfo ) )
    3. {
    4.  
    5. if (hitInfo.collider.tag == "DrawersBox"){
    6. Debug.Log("Box");
    7.  
    8. if(Input.GetMouseButtonDown(0)){
    9. hitInfo.collider.transform.position.forward * Time.deltaTime;
    10. }
    11.  
    12. }
    13. }
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You probably want transform.Translate; the code you have doesn't do anything, hence the error. transform.position would need a value assigned to it.

    --Eric
     
  3. Mirace

    Mirace

    Joined:
    Nov 29, 2010
    Posts:
    481
    Yes i noticed, i rewrote code so its now working