Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
zerosimms
15
Years of Service
User Offline
Joined: 25th Feb 2011
Location:
Posted: 3rd Apr 2011 00:30
Hey all

I'm trying to create a really simple bullet. So in my game I have a crosshair sprite centered. I've applied the 'control camera with arrow keys' on camera 1. Then created a small sphere(object 10) which is hidden.

Now, I'm trying to call the bullet (object 10) and make it "fire", by moving forward on the z axis really quickly
I want it to shoot from the center of current camera (1) position in my 3d world.

Here's my code:


The sphere appears and moves but it doesn't move from the current position of camera 1, which is what I'm after. Any ideas?
Many thanks

www.bensimms.co.uk
Daniel wright 2311
User Banned
Posted: 3rd Apr 2011 00:45


You need to point the object not hold its position to the camera with position object, if you do this the object will stick to the camera.

my signature keeps being erased by a mod So this is my new signature.
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 3rd Apr 2011 01:04
I guess he did that because when the button is pushed, the bullet gets back to the camera, and when released, the goes away. Makes the illusion of 'an other bullet'.

Though this is a very primitive method, one prime reason is that this way multiple shots can't be executed at the same time.

And yup, the move object command moves an object towards its rotation. So you need to adjust it according to the shooter's, or camera's angle.
zerosimms
15
Years of Service
User Offline
Joined: 25th Feb 2011
Location:
Posted: 3rd Apr 2011 17:42
Hey

Yeah Quel has hit the nail on the head, I'm trying to a) keep the code simple as and b) one shot per button press.

Thanks for the advice, I got it working by changing the code to the following:

if keystate(30)=1 then Position object 10, camera position x(1),camera position y(1),camera position z(1)
Set object to camera orientation 10
Show object 10
move object 10,10

YAY!

www.bensimms.co.uk

Login to post a reply

Server time is: 2026-07-11 14:57:03
Your offset time is: 2026-07-11 14:57:03