1. In my hockey game, shooting the puck is becoming a problem. How do I make t always shoot at the net?

2. find the differences between the coordinates and use trigonometry to give you a heading to the net. you shouldnt need Tan(), just Sin() or Cos().

Can't help much more without seeing your program.

3. I know of the functions, but I don't know trig yet

4. ok, gimme some numbers to play with and i'll try to work something our for you

5. the net is always here:
Net.x = 120
Net.y = 0

the player is all over

6. bear with me, i'm talkin to someone knowledgeable in this kinda thing.

7. OK here goes, the following is not VB code, so you'll have to decypher it, (should be easy)...

Bearing = arcsin[ |x| / sqrt(x²+y²)] + 90(x>=0)(y<=0) + 180(x<=0)(y<=0) + 270(x<=0)(y>=0)

|x| means absolute value of x
sqrt means square root
(y<=0) etc. are logical operators.

x,y are the differences in positions.

8. am I too late to join this discussion? Maybe you would like to work with vectors instead?

9. Whatever would be easier, wossname's or kedaman if you think vectors are easier than please post

10. Vectors are of course easier, they save a lot of time, both in programming and runtime trigs just consume a lot, hehe-.

Currently do you have a angle/speed set up? Or do you have anything else like vectors for the movement

11. Anyway i'm introducing you to vectors! Because that's exactly what you need The speed is composed by x and y components so addition goes with no trigs at all, that means a lot of speed gain when calculating new position for each each sequence. To handle the coordinates you use an UDT, for instance here's Coordinate32:
Code:
```Type Coordinate32
x As Single
y As Single
End Type

Function Scalar32ProjG2Vector(Target As Coordinate32, source As Coordinate32, Velocity As Single) As Coordinate32
Dim k As Single
k = speed / ((Target.y - source.y) ^ 2 + (Target.x - source.x) ^ 2) ^ 0.5
With Scalar32ProjG2Vector
.x = k * (Target.x - source.x)
.y = k * (Target.y - source.y)
End With
End Function
Function Vector32Add(V1 As Coordinate32, V2 As Coordinate32) As Coordinate32
.x = V1.x + V2.x
.y = V1.y + V2.y
End With
End Function```
Now the two functions i pasted here, the first one should project the result speed vector of target and source coordinates, whereas you set the target to the net and keep the source as the puck. VectorAdd should be just fine for moving the puck, just set the puck coordinate to what you return by adding the puck to the speed.

12. Kedaman, you like physics don't you? One of my favorite classes back in college (until we got into E&M and ticked off the prof).

13. ## hey Kaverin (friend)

I love physics and math, especially in combination with VB

14. If you ever need help with Particle/Wave Duality problems, then I'm your guy!

I got 97% in that module in college, but i still got a "D" overall, go figure!

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•