- Home /
Making raycasts go to the centre of the screen
I heard someone begin to explain this, and want to add it to my game.
var damage : float = 5;
function Update () {
var direction = transform.TransformDirection(Vector3.left);
var hit : RaycastHit;
var localOffset = transform.position;
if(Input.GetButtonDown("Fire1")){
if (Physics.Raycast (localOffset, direction, hit, 400)) {
Debug.DrawLine (localOffset, hit.point, Color.cyan);
print("we have fired!");
hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver);
}
}
}
How could I add it to this script?
Comment
Best Answer
Answer by demize2010 · May 20, 2011 at 08:49 AM
Player Prefs will work on mobile and PC platforms. There is some limitation on the web use:
http://unity3d.com/support/documentation/ScriptReference/PlayerPrefs.html
Note this is for a players local score only and is not a global high score table - you'll need to do a bit more work for that ;)
Your answer
Follow this Question
Related Questions
Making bullets go to the crosshair 1 Answer
How to increase score on hit 0 Answers
Hitmark display on hit 1 Answer
Object Reference not set to an instance of an object only appears occasionally? 1 Answer
different particle on enemy second hit 0 Answers