Page 1
Page 1
Started By
Message

Code for a game I'm developing-- in need of help// problem 1/99999999

Posted on 5/15/14 at 1:23 pm
Posted by TigerDik86
Baton Rouge
Member since Oct 2011
2982 posts
Posted on 5/15/14 at 1:23 pm
Ok. It's for a simple Melee hit. I'm trying to see if the melee works by allowing a message to pop up in the console. If it does.. then it works. but instead I'm facing this problem. here's the code.

#pragma strict

var TheDamage : int = 50;
var Distance : float;

function Update ()
{
if(Input.GetButtonDown("Fire1"))
{
var hit : RaycastHit;
if(Physics.Raycast (transform.position, transform.TransformDirection(Vector3.forward), hit));
{
Distance = hit.distance;
hit.transform.SendMessage("ApplyDamage", TheDamage, SendMessageOptions.DontRequireReciever);
}
}
}

The problem is

Distance = hit.distance;

The engine is stating that it was expecting : instead of =

If I change = to : to see the outcome, a whole mess of shite happens.

So, can anyone tell me with the problem?

TIA
This post was edited on 5/15/14 at 1:25 pm
Posted by SaintLSUnAtl
THE REAL MJ
Member since Jan 2007
22128 posts
Posted on 5/15/14 at 1:24 pm to
I took visual basic in college. I can create a text box for you
Posted by Gnar Cat21
Piña Coladaburg
Member since Sep 2009
16836 posts
Posted on 5/15/14 at 1:24 pm to
Ehhh you might have better luck on a game developer board or something.


Having said that, I'm gonna go with tree fiddy
Posted by SG_Geaux
Beautiful St George
Member since Aug 2004
77931 posts
Posted on 5/15/14 at 1:26 pm to
int = 288
Posted by Tactical1
Denham Springs
Member since May 2010
27104 posts
Posted on 5/15/14 at 1:27 pm to
Posted by TigerDik86
Baton Rouge
Member since Oct 2011
2982 posts
Posted on 5/15/14 at 1:29 pm to
quote:

int = 288


"OVERKILL"
Posted by jefforize
Member since Feb 2008
44077 posts
Posted on 5/15/14 at 1:32 pm to
God I hated java
Posted by sicboy
Because Awesome
Member since Nov 2010
77564 posts
Posted on 5/15/14 at 1:33 pm to
quote:

God: "I hated java."
Posted by jefforize
Member since Feb 2008
44077 posts
Posted on 5/15/14 at 1:37 pm to
Print "hello world!";
Posted by flyAU
Scottsdale
Member since Dec 2010
24848 posts
Posted on 5/15/14 at 1:40 pm to
quote:

Print "hello world!";


you beat me to it
Posted by taylork37
Member since Mar 2010
15320 posts
Posted on 5/15/14 at 1:46 pm to
I am taking a huge uneducated stab here, but you set Distance as a float, but is hit.distance also a float?

Posted by Eternalmajin
Member since Jun 2008
13050 posts
Posted on 5/15/14 at 1:51 pm to
quote:

if(Physics.Raycast (transform.position, transform.TransformDirection(Vector3.forward), hit));


Not sure if you copy-pasted the code in or typed it in, but you have a ; at the end of this if statement which is right before the Distance = hit.distance; line.
Posted by J Murdah
Member since Jun 2008
39779 posts
Posted on 5/15/14 at 2:18 pm to
am I solving for x?
Posted by illuminatic
Manipulating politicans&rappers
Member since Sep 2012
6962 posts
Posted on 5/15/14 at 2:21 pm to
I play video games.
Posted by TigerDik86
Baton Rouge
Member since Oct 2011
2982 posts
Posted on 5/15/14 at 3:21 pm to
quote:

Eternalmajin


I fricking love you
Posted by TigerDik86
Baton Rouge
Member since Oct 2011
2982 posts
Posted on 5/15/14 at 3:36 pm to
wait... no i don't. Still having a problem.
Posted by Eternalmajin
Member since Jun 2008
13050 posts
Posted on 5/15/14 at 3:37 pm to
When you get shite like that which makes no sense, always look on the lines before (or the lines that call that spot).

eta: Same issue? Or another?
This post was edited on 5/15/14 at 3:38 pm
Posted by TigerDik86
Baton Rouge
Member since Oct 2011
2982 posts
Posted on 5/15/14 at 3:56 pm to
actually,

after analyzing the script, your comment has led to the solution.

Thank you GB!
Posted by belowmebama
Member since Jul 2008
7303 posts
Posted on 5/15/14 at 8:04 pm to
I want a free copy.
Posted by okietiger13
From Sea to Shining Sea
Member since Jan 2007
10271 posts
Posted on 5/15/14 at 9:44 pm to
quote:

I want a free copy.

You would
first pageprev pagePage 1 of 1Next pagelast page
refresh

Back to top
logoFollow TigerDroppings for LSU Football News
Follow us on Twitter, Facebook and Instagram to get the latest updates on LSU Football and Recruiting.

FacebookTwitterInstagram