Jump to content

simple addForceAddPoint


AggrorJorn
 Share

Recommended Posts

I'm trying to push an object forward. To do this I use the AddForceAddPoint command. I've searched the rest of the forum and I kind a get stuck with difining the force.

	pick=CameraPick(camera,Vec3(GraphicsWidth()/2,GraphicsHeight()/2,2.0),0,0)
if pick~=nil then
	if MouseDown(1)==1 then
		centerY=(GraphicsHeight()/2)
		if (centerY >= currentY) then 
			texty = 1
			campos = EntityPosition(fw.main.camera);
			force= Vec3(pick.x-campos.x,pick.y-campos.y,pick.z-campos.z)
			NormalizeVec3(force);
			force.x=10
			force.y=0
			force.z=0
			entity:AddForceAtPoint(force,pick.entity)

 

When I hold down the left mouse button and try to move a box, I recieve the error: index for obect is a valid filed or method.

Can someone tell me what I'm doing wrong here?

Link to comment
Share on other sites

Good to know, but that wasn't the problem I think.

 

depends if you are running it outside of the editor or inside... outside appears to require uppercase and inside the editor requires lowercase

 

also this line:

entity:AddForceAtPoint(force,pick.entity)

will not work... that command is looking for two Vec3's... so its looking for this:

entity:AddForceAtPoint(force,pick.position)

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

depends if you are running it outside of the editor or inside... outside appears to require uppercase and inside the editor requires lowercase

 

So what is this all about? Are you saying if I run from engine.exe vs editor.exe the case is different? That's not cool.

Link to comment
Share on other sites

I forgot to mention that the script editor selects the following line after the error:

index for obect is a valid filed or method.

force=Vec3(pick.x-campos.x,pick.y-campos.y,pick.z-campos.z)]

 

thats why i told you above that the position of a pick is pick.position with pick.position.x, pick.position.y, and pick.position.z as its components... there is no pick.x. pick.z...

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...