Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // BulletObject bullet here is a placeholder for the bullet being spawned, which has some
- // assumed properties and methods common to all bullets.
- void spawnBulletClientSide(BulletObject bullet, Vector3 pos, Vector2 velocity, float lag_time) {
- // todo: add the bullet to the scene, this will vary by platform
- // We will assume that we're passed a clone that just needs to be placed in the scene
- // or that it is a class type and instantiated, leaving us with a reference to it
- // which for simplicity I will simply refer to as the same bullet parameter passed to this method
- // place the bullet where it was spawned
- bullet.position = pos;
- // give it velocity
- bullet.velocity = velocity;
- // tell the bullet to execute its move() function for a time interval equal to the predicted lag time
- // this
- bullet.move(lag_time);
- }
- /** BulletObject.move(float time) **/
- void move(float time) {
- if(this.hasGravity) {
- pos += velocity * time + 0.5 * gravity_accel * time * time;
- }
- else {
- pos += velocity * time;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement