- Home /
Question by
zak666 · Aug 23, 2016 at 05:37 AM ·
scriptingbasicsraycasthit
trying to send a message by recast for guns but I'm getting: error CS1525: Unexpected symbol `{'
hey guys trying to use a simple guns script using raycasting to damage whatever i am hitting, tho I'm getting: error CS1525: Unexpected symbol `{'
if (Physics.Raycast(transform.position, transform.forward, Hit){
using UnityEngine;
using System.Collections;
public class PlayerControllerWizards : MonoBehaviour {
public float Speed = 20;
public float turnspeed = 50;
public float BoosterSpeed = 30f;
public float UserFighetrHp = 100;
//Ammo/guncontroll
public Transform BulletSpawn;
public GameObject MachGunBullets;
public GameObject Explosion;
public AudioClip HitAudio;
public AudioClip Explostion;
public AudioClip Machshot;
// Booster Controll
public Light Thrusterlight;
public Light Thrusterlight2;
public bool Iscontrollable = true;
public Raycast Hit;
void LateUpdate () {
transform.Translate (Vector3.forward * Speed * Time.deltaTime);
Vector3 fwd = transform.TransformDirection(Vector3.forward);
//Gunm-Fire Controll____________________________________________________________________________________________
if (Input.GetButton ("Shoot")) {
MachGunBullets.SetActive (true);
if (Physics.Raycast(transform.position, transform.forward, Hit){
if (Hit.collider.tag == "red_Team_fighter" )
{
Hit.collider.SendMessageUpwards ("MachGunsDamage", SendMessageOptions.DontRequireReceiver);
}
if (Hit.collider.tag == "Blue_Team_fighter" )
{
Hit.collider.SendMessageUpwards ("MachGunsDamage", SendMessageOptions.DontRequireReceiver);
}
} // END RAYCAST
}
//Spaceshipcontrolles________________________________________________________________________________________
float horizontal = Input.GetAxis ("Horizontal") * turnspeed;
float vertical = Input.GetAxis ("Vertical") * turnspeed;
horizontal *= Time.deltaTime;
vertical *= Time.deltaTime;
transform.Rotate (Vector3.up, horizontal);
transform.Rotate (Vector3.right, vertical);
//Booster Controll________________________________________________________________________________________
if (Input.GetButton ("Boost")) {
transform.Translate (Vector3.forward * BoosterSpeed * Time.deltaTime);
Thrusterlight.intensity = 0.7f;
Thrusterlight2.intensity = 0.7f;
}
if (Input.GetButtonUp ("Boost")) {
Thrusterlight.intensity = 0.44f;
Thrusterlight2.intensity = 0.44f;
}
}
}
// End Late Update________________________________________________________________________________________
//------------------------------------------------------------------------------------------------------------------------
void OnCollisionEnter(Collision other) {
if (other.gameObject.CompareTag ("EAIBullet")) {
Destroy (other.gameObject);
UserFighetrHp -= 1;
}
if (other.gameObject.CompareTag ("EAIFlackShell")) {
UserFighetrHp -= 100;
}
}
//------------------------------------------------------------------------------------------------------------------------
}
Comment
Answer by saschandroid · Aug 23, 2016 at 05:50 AM
Line 40: missing ")"
if (Physics.Raycast(transform.position, transform.forward, Hit){
has to be
if (Physics.Raycast(transform.position, transform.forward, Hit) ) {
Your answer
Follow this Question
Related Questions
Decreasing health on (raycast)hit -1 Answers
How would i make an object change color every second? 0 Answers
My GameObject (c#) haven't sprite defined 4 Answers
New to Raycasts, trouble using "hit" 0 Answers
Animator Controller 0 Answers