Jump to content

Assigning property to a node and using it from Script


photo

Recommended Posts

Hi,

 

I have a car model adn two nodes. I want to move them from script code. 

 

But I do not know how to do?

 

I thiink I should assign a porperty first. But I do not know how to do it?

 

Is there any tutorial?

Link to comment

Hi Yiğit,

 

Do you work with City Traffic system? If you do, there is a tutorial on Importing car to the world

In this tutorial, you'll inherit the Car entity's property.

But if you don't use City Traffic system, name these nodes in UnigineEditor, for example, car_1 and car_2 and then, in the script use engine.editor.getNodeByName()  to get the node and move it from the script. This article on basic object movements will help you to move it! :)

 

Thanks!

Link to comment

By default, my nodes have car_wheel property. 

 

And they are turning. I want them not to turn automatically. Just stay still.

 

Should I create a new property? How? 

Link to comment

Hi Yiğit,

 

Do you assign the car_wheel property on your own? Because UnigineEditor shouldn't assign car_wheel property as default (if we're talking about City Traffic system).

 

Could you provide more information (for example, step-by-step instructions) and a test scene with your nodes for faster investigation?

 

Thanks!

Link to comment

First of all I created a new property called car_blower. Then I assigned it to my node from editor.

 

In the script I found this node by using: In here my aim is t ocreate a fiexd joint with car and my node(blower).

if((property.getName() == "car_blower"))
Body wheel_body = child.getBody();
 
Mat4 transform = object.getWorldTransform();
Body parent_body = object.getBody();
 
JointFixed j = class_remove(new JointFixed(parent_body,wheel_body));
 
j.setMaxForce(0.0f);
j.setMaxTorque(1.0f);
j.setLinearRestitution(0.8f);
j.setAngularRestitution(0.2f);
j.setLinearSoftness(1.0f);
j.setAngularSoftness(1.0f);
j.setNumIterations(1);
 
j.setAnchor0(Vec3(0,0,0));
j.setAnchor1(Vec3(0,0,0));
j.setWorldAnchor(object.getWorldPosition());

Now my problem is my node(blower) is not moving with my car. How should I move it with my car?

 

I think my problem is changed from property to fixed joint  :rolleyes:

Link to comment

Hi Yiğit,

 

Unfortunately, we need a test scene for further investigation of your problem, because you provided not enough information about your problem. Could you provide it?

 

Thanks!

Link to comment
×
×
  • Create New...