Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Motion in 3d Space


Recommended Posts

Hello all,

 

I am having trouble positioning and moving an instanced entity. Basically, I am trying to instance a snowball in front of my creature and have him throw that snowball at the target. When I instance the object, I can force the position, but I don't know how to calculate the position relative to the player facing.

 

I also do not know how to calculate and apply the correct the velocity vector to be applied in order for the snowball to be thrown. As part of this, I would also like to be able to adjust this trajectory during the physics update in case I need to track a target. I do not want to use the Nav Mesh related commands of move or follow as I do not want the snowball to be bound to only navigable terrain.

 

I have scoured the forums and reviewed the Project Saturn tutorials for a few days now, but I haven't been able to find a solution. I would GREATLY appreciate any help you can provide. I thought the Transform command might be the right idea, but it didn't react the way I expected.

 

Example Code:

 

local Snowball = nil --entity

local Snowball_Model = nil-- entity

local Origin = Vec3(0,0,0)

 

self.Snowball_Model = Prefab:Load("Prefabs/Weapons/Snowball.pfb")

self.Origin = Thrower:GetPosition(true)

self.Snowball = self.Snowball_Model:Instance()

 

self.Snowball:SetPosition(self.Origin.x + 1, self.Origin.y +1, self.Origin.z + 1)

--self.Snowball:SetPosition(Transform:Point(1,1,1,self.Origin, nil) --Tried this but it placed

--the snowball far away from the model.

self.Snowball:Point(self.Target)

 

Thanks in advance,

 

Allaric

Link to post
Share on other sites

Thank you Macklebee! I was able to use the example and noodle through spawning and tossing the snowball! I had to use SetVelocity() on the UpdatePhysics in order to track the target instead of just adjusting the flight path (AddForce made it hit warp speed for obvious reasons). It would be cool if I could just adjust the velocity to allow tracking and leave an arc from an initial AddForce Y value, but it works.

 

I do have an issue with the target entity since I am using Point(). With the pivot on the floor I hit everyone's feet, and with Point() it doesn't seem like there is a way to just add +1 Y value to the axis. I saw in the tutorial that a suggestion was to create a target Pivot and attach it to the character models, but I was wondering if there was a way to just add a little height instead of creating additional entities.

 

Thanks again for your help thus far.

Link to post
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.

×
×
  • Create New...