Log in or register to post comments

AddForce Issue with vuforia

February 12, 2014 - 3:44am #1

Hi Building a pyshic Game with Vuforia for a Art festival,

The physic works, but when I add's the vuforia SDK

I get this:

Assets/PlayerMovement.cs(22,27): error CS1061: Type `UnityEngine.Transform' does not contain a definition for `AddForce' and no extension method `AddForce' of type `UnityEngine.Transform' could be found (are you missing a using directive or an assembly reference?)

It doesn't seem to recognise the force element?

 

My Script::

using UnityEngine;

using System.Collections;

public class PlayerMovement : MonoBehaviour {

                             public float speed = 1.0f;

                             public float gravity = 9.98f;

                             public Transform gravitySource;

                             private Vector3 gravityVector;

                             // Use this for initialization

                             void Start () {

                            

                             }

                             // Update is called once per frame

                             void FixedUpdate () {

                                                          gravityVector = (gravitySource.position - transform.position).normalized*gravity;

                                                          //transform.position += gravityVector*Time.deltaTime;

                                                          transform.AddForce(gravityVector);

                                                          transform.rotation = Quaternion.LookRotation(-gravityVector);

                             }

                             void OnCollisionStay(Collision collision){

                             if(collision.collider == gravitySource.collider)

                             {

 

                                                                                       transform.position = gravitySource.position - gravityVector.normalized*(gravitySource.localScale.x/2.0f);

 

                             }

                             }

 

}

 

 

 

 

Best Regards

daniel

Simulacrum.dk

 

 

 

AddForce Issue with vuforia

February 12, 2014 - 6:34am #4

Happy that the first issue is solved.

Concerning the second issue (sdktools.jar), I doubt this is caused by Vuforia; but if you have upgraded the project, make sure to read this:

https://developer.vuforia.com/resources/dev-guide/migrating-your-unity-project

 

AddForce Issue with vuforia

February 12, 2014 - 5:33am #3

Hi again.

Big thanks it's working! did't see that:-)

I have another issue when compiling out to Android for test, just opgraded to the newest Vuforia SDK and unity3d 4.3.2f1

Error building Player: CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details.
 
C:\Program Files (x86)\Java\jre7\bin\java.exe -Xmx1024M -Dcom.android.sdkmanager.toolsdir="C:/sdk\tools" -Dfile.encoding=UTF8 -jar "C:/Program Files (x86)/Unity4.3.2f1/Editor/Data/BuildTargetTools/AndroidPlayer\sdktools.jar" -
 
Been looking in forums some saying, it beacuse you have two sdktools.jar I dont'  others says player settings being looking is into it is it Vuforia?
1. Have done Reimport to unity3d-
2. Download the newest Java plug--
3.Check configuration player setting-
 
Best
daniel
 

AddForce Issue with vuforia

February 12, 2014 - 3:58am #2

You are using this code:

transfrom.AddForce()

However, the Transform class does not expose an AddForce method, see the script reference:

http://docs.unity3d.com/Documentation/ScriptReference/Transform.html

It is surprising that the error only appears when you import Vuforia.

Actually, the correct cod should be:

transform.rigidbody.AddForce(  )

 

 

Log in or register to post comments