JuAnY

[HELP] Shoot or move object

Recommended Posts

Hi guys, I'm trying to learn how to do a resource to hold a ball when the player collides, and then click to shoot it in the current camera direction.
Im a little lost :/, I searched and tried with moveObejct but the result was too badly...

Here some portions of code:

ball = createObject(1598, 1347.8164, 2127.0234, 10.3, 300, 360, 300, false)
attachElements ( ball, player, 0, 0.5, -0.75 )
local rotz = tonumber(getPedRotation(player))
local xt,yt,zt = getElementPosition(player)
detachElements(ball, player)
xt = xt + (math.cos(math.rad(rotz+90)) * 1.2)
yt = yt + (math.sin(math.rad(rotz+90)) * 1.2)
moveObject(ball, 2500, xt, yt, zt, math.random(10, 90), math.random(10, 90), math.random(10, 90))
			

If you can help me with something or give me a hint, I will be grateful!
 

Share this post


Link to post

Just use OOP, it's much easier with it.

  • Thanks 1
  • Confused 1

Share this post


Link to post

Check ballthrower resource from the community, some sweet throwing code there

  • Thanks 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.