#how do i (make a projectile) aim where my mouse is?

30 messages · Page 1 of 1 (latest)

dawn cradle
#

i am useing
world.spawnProjectile("erchiusbomb", {mcontroller.xPosition(), mcontroller.yPosition()}, entity.id(), {activeItemAnimation.ownerAimPosition()}, true, {power=7, speed=25, timeToLive = 0.5})
how do i make it aim where my mouse cursor is and not a predermind angle

#

how do i (make a projectile) aim where my mouse is?

keen sleet
#

Replace {activeItemAnimation.ownerAimPosition()} with activeItem.ownerAimPosition()

#

Also, you can just replace {mcontroller.xPosition(), mcontroller.yPosition()} with mcontroller.position()

dawn cradle
#

thanks ima try it

#

ok its now firering but its (fire) angle dosent change when i move my mouse

keen sleet
#

oh wait

#

that doesn't work

#

Try world.distance(activeItem.ownerAimPosition(), mcontroller.position())

dawn cradle
#

nice this works (if i chage the speed to negitive)

keen sleet
#

I edited it

#

Do you have mcontroller.position() followed by activeItem.ownerAimPosition()?

dawn cradle
#

in the table you showed me?

keen sleet
#

Did you put this?
world.distance(activeItem.ownerAimPosition(), mcontroller.position())

#

or this?
world.distance(mcontroller.position(), activeItem.ownerAimPosition())

dawn cradle
#

i have the 2nd one

keen sleet
#

Put the first one

dawn cradle
#

k

keen sleet
#

It should point toward your cursor without using negative speed

dawn cradle
#

it does thanks

keen sleet
#

No problem 👍

dawn cradle
#

also is there any way i could make it deviate a little like bullet spread

keen sleet
#

In Lua, that's a little bit complicated to pull off

#

Actually

dawn cradle
#

mainly like just like + or - 1 degres whatever direction

keen sleet
#

This'll require a little bit of digging

dawn cradle
#

k

keen sleet
#

Use vec2.rotate(world.distance(activeItem.ownerAimPosition(), mcontroller.position()), sb.nrand(inaccuracy, 0))

#

You will need to add the line require "/scripts/vec2.lua" at the beginning of your Lua script though

dawn cradle
#

thanks a lot for the help it now has in acuracy and aiming n stuff