Hi,
I’m trying to get Unity to send a wwwform to a PHP file every time every time the player makes a new move - left, right, forward etc. However I am having trouble getting the info out via wwwform: I keep getting the following error:
MissingMethodException: Method not found: ‘UnityEngine.WWWForm.addField’.
Here’s the full code the WWWForm references are right near the bottom:
var moveSpeed = 1.0;
var turnSpeed = 1.0;
var direction = "still";
var tale="I woke up in the middle of nowhere";
var newStatement;
var oldStatement ="nothing";
function Update()
{
if(Input.GetButtonDown("Jump"))
{
transform.position.z += 1.0;
direction = "Jump";
}
if(Input.GetButton("Forward"))
{
transform.position += transform.forward * moveSpeed * Time.deltaTime;
direction = "forward";
}
if(Input.GetButton("Back"))
{
transform.position += -transform.forward * moveSpeed * Time.deltaTime;
direction = "back";
}
if(Input.GetButton("Left"))
{
transform.eulerAngles.y += -turnSpeed * Time.deltaTime;
direction = "Left";
}
if(Input.GetButton("Right"))
{
transform.eulerAngles.y += turnSpeed * Time.deltaTime;
direction = "Right";
}
if(direction==="Jump"){
newStatement = "jump";
}
if(direction==="forward"){
newStatement = "forward";
}
else if(direction==="back"){
newStatement = " back";
}
else if(direction==="Left"){
newStatement = "left";
}
else if(direction==="Right"){
newStatement = "right";
}
else{
newStatement = "stopped";
}
if(newStatement!=oldStatement){
addtoDB();
}
}
function addtoDB()
{
var form = new WWWForm();
var phpurl = "http://localhost/writer.php";
var sendR = WWW(phpurl,form);
if(direction==="Jump"){
form.addField("value", "1");
yield sendR;
print("addtoDB is working");
}
if(direction==="Forward"){
form.addField("value", "1");
print("addtoDB is working");
yield sendR;
}
}
Could anyone help me on what I am doing wrong?
Thanks,
David