Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by pwn_dhami · Dec 10, 2015 at 05:07 PM · unity 4.6

what is the meaning of this error BCE0019: 'position' is not a member of 'Object'. when i switch to android this error occurs but for pc platform code works fine no error, please tell me the reason behind this error.

/*i change the var path : Array; to var path : Transform[]; but path is not being created. and i remove

paragmastrict from script and put it again but not work.*/

var path : Array;

var pathGroup : Transform;

var maxSteer : float = 15.0 ;

var wheelFL : WheelCollider;

var wheelFR : WheelCollider;

var wheelRL : WheelCollider;

var wheelRR : WheelCollider;

var currentPathObj : int;

//var dir : float;

var centerOfMass : Vector3;

var distanceFromPath : float = 20;

var maxTorque : float = 50;

var currentSpeed : float ;

var topSpeed : float = 150;

var decellerationSpeed = 10;

var brakeingMesh : Renderer;

var idleBrakeLight : Material;

var activeBrakeLight : Material;

var isBrakeing : boolean;

var inSector : boolean ;

var sensorLength : float = 5;

var frontSensorStartPoint : float = 5;

var frontSensorSideDist : float ;

var frontSensorsAngle : float = 30;

var sidewaySensorLength : float =5 ;

var avoidSpeed : float = 10;

private var flag : int = 0;

var reversing : boolean = false;

var reverCounter : float = 0.0;

var waitToReverse : float = 3.0;

var reverFor : float = 1.5;

var respawnWait : float = 5;

var respawnCounter : float = 0.0;

function Start(){

rigidbody.centerOfMass = centerOfMass;

GetPath();

}

function GetPath(){

var path_objs : Array = pathGroup.GetComponentsInChildren(Transform);

path = new Array();

for(var path_obj : Transform in path_objs){

if(path_obj != pathGroup)

  path[path.length] = path_obj;
 }

}

function Update(){

if(flag == 0)

GetSteer();

Move();

BrakeingEffect();

Sensors();

Respawn();

}

function GetSteer() {

var steerVector : Vector3 = transform.InverseTransformPoint(Vector3(path[currentPathObj].position.x ,

transform.position.y , path[currentPathObj].position.z)) ;

var newSteer : float = maxSteer *(steerVector.x / steerVector.magnitude);

//dir = steerVector.x / steerVector.magnitude;

wheelFL.steerAngle = newSteer;

wheelFR.steerAngle = newSteer;

if(steerVector.magnitude <= distanceFromPath){

currentPathObj++;

}

if(currentPathObj >= path.length){

currentPathObj = 0;

}

}

function Move(){

currentSpeed = 2 (22/7) wheelRL.radius wheelRL.rpm 60/1000;

currentSpeed = Mathf.Round(currentSpeed);

if(currentSpeed <= topSpeed && !inSector){

if(!reversing){

wheelRL.motorTorque = maxTorque;

wheelRR.motorTorque = maxTorque;

}

else {

wheelRL.motorTorque = -maxTorque;

wheelRR.motorTorque = -maxTorque;

}

wheelRL.brakeTorque = 0;

wheelRR.brakeTorque = 0;

}

else if(!inSector){

wheelRL.motorTorque = 0;

wheelRR.motorTorque = 0;

wheelRL.brakeTorque = decellerationSpeed ;

wheelRR.brakeTorque = decellerationSpeed;

}

}

function BrakeingEffect(){

if(isBrakeing == true){

brakeingMesh.material = activeBrakeLight ;

}

else

brakeingMesh.material = idleBrakeLight;

}

function Sensors(){

flag = 0 ;

var avoidSenstivity : float =0 ;

var pos : Vector3 ;

var hit : RaycastHit ;

var rightAngle = Quaternion.AngleAxis(frontSensorsAngle , transform.up) * transform.forward;

var leftAngle = Quaternion.AngleAxis(-frontSensorsAngle , transform.up) * transform.forward;

pos = transform.position;

pos += transform.forward*frontSensorStartPoint;

// brakeing sensor.

if(Physics.Raycast(pos,transform.forward,hit,sensorLength)){

if(hit.transform.tag != "Terrain"){

flag++;

wheelRL.brakeTorque = decellerationSpeed;

wheelRR.brakeTorque = decellerationSpeed;

Debug.DrawLine(pos,hit.point,Color.red);

}

} else{

wheelRL.brakeTorque = 0;

wheelRR.brakeTorque = 0;

}

//front straight right sensor.

pos += transform.right*frontSensorSideDist;

if(Physics.Raycast(pos ,transform.forward , hit , sensorLength)){

if(hit.transform.tag != "Terrain"){

flag++;

avoidSenstivity -= 1;

Debug.Log("Avoiding");

Debug.DrawLine(pos,hit.point,Color.white);

}

}

else if(Physics.Raycast(pos , rightAngle , hit , sensorLength)){ //front angled right sensor.

if(hit.transform.tag != "Terrain"){

avoidSenstivity -= 0.5;

flag++;

Debug.DrawLine(pos,hit.point,Color.white);

}

}

// front straight left sensor.

pos = transform.position;

pos += transform.forward*frontSensorStartPoint;

pos -= transform.right*frontSensorSideDist;

if(Physics.Raycast(pos,transform.forward,hit,sensorLength)){

if(hit.transform.tag != "Terrain"){

flag++;

avoidSenstivity += 1;

Debug.Log("Avoiding");

Debug.DrawLine(pos,hit.point,Color.white);

}

}

else if(Physics.Raycast(pos,leftAngle,hit,sensorLength)){ //front angles left sensor.

if(hit.transform.tag != "Terrain"){

flag++;

avoidSenstivity += 0.5;

Debug.DrawLine(pos,hit.point,Color.white);

}

}

// rightsideWay sensor.

if(Physics.Raycast(transform.position,transform.right,hit,sidewaySensorLength)){

if(hit.transform.tag != "Terrain"){

flag++;

avoidSenstivity -= 0.5;

Debug.DrawLine(transform.position,hit.point,Color.white);

}

}

// leftsideWay sensor.

if(Physics.Raycast(transform.position,-transform.right,hit,sidewaySensorLength)){

if(hit.transform.tag != "Terrain"){

flag++;

avoidSenstivity += 0.5;

Debug.DrawLine(transform.position,hit.point,Color.white);

}

}

pos = transform.position;

pos += transform.forward*frontSensorStartPoint;

//front mid sensor.

if(avoidSenstivity == 0){

if(Physics.Raycast(pos,transform.forward,hit,sensorLength)){

if(hit.transform.tag != "Terrain"){

if(hit.normal.x < 0)

avoidSenstivity = -1;

else

avoidSenstivity = 1;

Debug.DrawLine(pos,hit.point,Color.white);

}

}

}

if(rigidbody.velocity.magnitude < 2 && !reversing){

reverCounter += Time.deltaTime;

if(reverCounter >= waitToReverse){

reverCounter = 0;

reversing = true;

}

}

else if(!reversing){

reverCounter = 0;

}

if(reversing){

avoidSenstivity *= -1;

reverCounter += Time.deltaTime;

if(reverCounter >= reverFor){

reverCounter = 0;

reversing = false; }

}

if(flag!= 0)

AvoidSteer(avoidSenstivity);

}

function AvoidSteer(senstivity : float){

wheelFL.steerAngle = avoidSpeed * senstivity;

wheelFR.steerAngle = avoidSpeed * senstivity;

}

function Respawn(){

if(rigidbody.velocity.magnitude < 2){

respawnCounter += Time.deltaTime;

if(respawnCounter >= respawnWait){

if(currentPathObj == 0){

transform.position = path[path.length -1].position;

}

else{

transform.position = path[currentPathObj -1 ].position;

}

respawnCounter = 0;

transform.localEulerAngles.z = 0;

}

}

}

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
â–¼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image gjf · Dec 09, 2015 at 06:47 PM 0
Share

when posting code, please format it so that it's readable to people trying to help you.

avatar image pwn_dhami · Dec 10, 2015 at 10:27 AM 0
Share

sorry for that but i won't know how to formate it .sorry again.

avatar image Jessespike pwn_dhami · Dec 10, 2015 at 06:56 PM 0
Share

Unity Answers - How do you format scripts in Unity Answers?

Press the "101010" button

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Jessespike · Dec 10, 2015 at 06:35 PM

JS Array class won't work with #pragma strict code, unless you manually cast to the correct type when retrieving items.

unity Wiki - Choosing the right collection type

Try changing

  var path : Array;

to

  import System.Collections.Generic;
  var path : List.<Transform> = new List.<Transform>();

and revise your GetPath() function. I'm not sure what you're trying to do, but it doesn't look right. Try something like:

 function GetPath(){    
     var path_objs : Array = pathGroup.GetComponentsInChildren(Transform);
 
     for(var path_obj : Transform in path_objs){
         if(path_obj != pathGroup)
             path.Add(path_obj);
     }
 }

you'll also need change all of path's ".length" to ".Count"

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
â–¼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image pwn_dhami · Dec 11, 2015 at 08:53 AM 0
Share

Hi Jessespike , thanks for your relpy , its works . thanks alot Jessespike.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How to make questions & answers random in my script C#? 1 Answer

Move enemy only touching border 1 Answer

Arguement Out Of Range (ONLY IN BUILD) 1 Answer

A question about Unity Web Player 0 Answers

iOS 64 Bit - game freezes for some seconds? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges