Jump to content
Moni Telling

Mouse look actions

Recommended Posts

It's not that hard, but there's a lot of boilerplate code needed to get mouselook touches reliably. Here's some code of mine which does that. This is a little wearable object which lets you click on things in mouselook and read their pathfinding properties. You can adapt that to do other things. Enjoy.

Share this post


Link to post
Share on other sites
32 minutes ago, animats said:

It's not that hard, but there's a lot of boilerplate code needed to get mouselook touches reliably. Here's some code of mine which does that. This is a little wearable object which lets you click on things in mouselook and read their pathfinding properties. You can adapt that to do other things. Enjoy.

thank you! I'm looking now!

Share this post


Link to post
Share on other sites
11 minutes ago, Moni Telling said:

how do I get  it to work like a bowling ball like a power up after holding it for like 5 seconds it speed is 100.

Oh, you're scripting the touched object, not the avatar doing the touching. Completely different.  Read up on touch events.

Here's a cute approach. Make the object a physical sphere. Detect touches with touch_start and touch_end. At touch_start, use llDetectedTouchNormal to get the direction to move. At touch_end, get the time difference since the touch_start, and use that to compute your "power". The longer you hold down the mouse, the more power.  Multiply that by the inverse of the touch normal and apply it as an impulse with llApplyImpulse. The object will go rolling off opposite the touch point. If you want the object to stay on the ground, zero out the Z term of the vector before applying the impulse. Have fun bowling!

Share this post


Link to post
Share on other sites
12 hours ago, Moni Telling said:

how do I get  it to work like a bowling ball like a power up after holding it for like 5 seconds it speed is 100

This sounds like it would be similar to a gun script - in that the avatar would create a projectile (bowling ball in this case) and "shoot" it forward relative to the direction they are currently facing in mouselook. The extra catch here is that you'd like to alter the strength of the throw based on how long the user holds the button before firing. Does this sound accurate?

Assuming this is what you're trying to do, then you would need to study the control event, as this that would be what is responding to the user's button presses. The control event triggers whenever a button is pressed, whenever a button is released, and also continuously while a button as being held down. This can be used to suit your needs quite easily.

Generally speaking, you would configure your control event to increment a "power" variable while the user holds down the desired button and then, when the user releases the button, you would "fire" the projectile using the current value of the power variable. You'd also want to reset the power variable to zero when the projectile is fired, to get ready for the next shot.

Visually speaking, I imagine the avatar would wear a bowling ball as an attachment in their hand. This would effectively be the "gun". When the player "throws" the ball, the worn attachment turns itself invisible and rezzes the projectile bowling ball simultaneously to simulate the effect of them throwing it out of their hands.

 

Edited by Fenix Eldritch

Share this post


Link to post
Share on other sites
3 hours ago, Fenix Eldritch said:

This sounds like it would be similar to a gun script - in that the avatar would create a projectile (bowling ball in this case) and "shoot" it forward relative to the direction they are currently facing in mouselook. The extra catch here is that you'd like to alter the strength of the throw based on how long the user holds the button before firing. Does this sound accurate?

Assuming this is what you're trying to do, then you would need to study the control event...

That's what it turned out to be. The object is a football that gets "kicked". I was thinking the original poster wanted to push around an object that's already in world, as in a pool table game.

Share this post


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.

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...