- Home /
This question was
closed May 24, 2014 at 07:39 AM by
Fattie for the following reason:
Duplicate Question
Question by
NutellaDaddy · May 23, 2014 at 06:01 PM ·
normalshitstatement
Only assignment, call, increment, decrement, and new object expressions can be used as a statement
If I can't declare it as a statement should I just wait until I need to use it? It's a very simple question ,but I need to know if I[m going about this the right way. How could I store hit.normal in a variable?
Here's the script:
using UnityEngine;
using System.Collections;
//
//THIS SCRIPT CONTROLS THE MOVEMENT OF THE PLAYER
//
[RequireComponent (typeof (Rigidbody))]
public class PlayerMovement : MonoBehaviour
{
//ALL OF THE PUBLIC VARIABLES
public float walkSpeed = 6.0f;
public float runSpeed = 12.0f;
public float jumpSpeed = 8.0f;
//ALL OF THE PRIVATE VARIABLES
private Vector3 moveDirection;
private float speed;
void Start ()
{
speed = walkSpeed;
}
void Update ()
{
moveDirection = new Vector3 (Input.GetAxisRaw ("Horizontal"),0, Input.GetAxisRaw ("Vertical")).normalized;
RaycastHit hit;
Physics.Raycast (transform.position, -Vector3.up, out hit);
if (Physics.Raycast (transform.position, -Vector3.up, out hit))
{
hit.normal;
}
}
void FixedUpdate()
{
rigidbody.MovePosition (rigidbody.position + transform.TransformDirection(moveDirection) * speed * Time.deltaTime);
}
}
Comment
Best Answer
Answer by tanoshimi · May 23, 2014 at 06:04 PM
"How could I store hit.normal in a variable?"
Vector3 hitNormalSavedInAVariable;
hitNormalSavedInAVariable = hit.normal;
?
Tano, be sure to just CLOSE pointless questions like this after answering them and ticking your own answer